Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete persisted subscriptions that are in subscription resumption state when a subscribeRequest command comes in with keepSubscription flag set to false from the same subscriber #37741

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
34 changes: 33 additions & 1 deletion src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,14 +723,46 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest
if (handler->IsFromSubscriber(*apExchangeContext))
{
ChipLogProgress(InteractionModel,
"Deleting previous subscription from NodeId: " ChipLogFormatX64 ", FabricIndex: %u",
"Deleting previous active subscription from NodeId: " ChipLogFormatX64 ", FabricIndex: %u",
ChipLogValueX64(apExchangeContext->GetSessionHandle()->AsSecureSession()->GetPeerNodeId()),
apExchangeContext->GetSessionHandle()->GetFabricIndex());
handler->Close();
}

return Loop::Continue;
});

#if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
if (mpSubscriptionResumptionStorage != nullptr)
{
SubscriptionResumptionStorage::SubscriptionInfo subscriptionInfo;
auto * iterator = mpSubscriptionResumptionStorage->IterateSubscriptions();

while (iterator->Next(subscriptionInfo))
{
if (subscriptionInfo.mNodeId == apExchangeContext->GetSessionHandle()->AsSecureSession()->GetPeerNodeId() &&
subscriptionInfo.mFabricIndex == apExchangeContext->GetSessionHandle()->GetFabricIndex())
{
ChipLogProgress(InteractionModel,
"Deleting previous non-active subscription from NodeId: " ChipLogFormatX64
", FabricIndex: %u",
ChipLogValueX64(subscriptionInfo.mNodeId), subscriptionInfo.mFabricIndex);
mpSubscriptionResumptionStorage->Delete(subscriptionInfo.mNodeId, subscriptionInfo.mFabricIndex,
subscriptionInfo.mSubscriptionId);
}
}
iterator->Release();

// If we have no subscriptions to resume, we can cancel the Timer, to make sure it is cleared in the case,
// we deleted a subscription in resumption mode.
if (!HasSubscriptionsToResume())
{
mpExchangeMgr->GetSessionManager()->SystemLayer()->CancelTimer(ResumeSubscriptionsTimerCallback, this);
mSubscriptionResumptionScheduled = false;
mNumSubscriptionResumptionRetries = 0;
}
}
#endif // CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION && CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
}

{
Expand Down
Loading