From 1085480194a8b55878ddd54a1161a0d6e2815969 Mon Sep 17 00:00:00 2001 From: Jeff Tung <100387939+jtung-apple@users.noreply.github.com> Date: Thu, 9 Mar 2023 09:36:02 -0800 Subject: [PATCH] [ICD] Subscription resumption logic should skip subscriptions created during startup wait time (#25545) * [ICD] Subscription resumption logic should skip subscriptions created during startup wait time --- src/app/InteractionModelEngine.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index f65fa59f340f94..3fe465637e225c 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -1638,6 +1638,21 @@ void InteractionModelEngine::ResumeSubscriptionsTimerCallback(System::Layer * ap auto * iterator = imEngine->mpSubscriptionResumptionStorage->IterateSubscriptions(); while (iterator->Next(subscriptionInfo)) { + // If subscription happens between reboot and this timer callback, it's already live and should skip resumption + if (Loop::Break == imEngine->mReadHandlers.ForEachActiveObject([&](ReadHandler * handler) { + SubscriptionId subscriptionId; + handler->GetSubscriptionId(subscriptionId); + if (subscriptionId == subscriptionInfo.mSubscriptionId) + { + return Loop::Break; + } + return Loop::Continue; + })) + { + ChipLogProgress(InteractionModel, "Skip resuming live subscriptionId %" PRIu32, subscriptionInfo.mSubscriptionId); + continue; + } + auto requestedAttributePathCount = subscriptionInfo.mAttributePaths.AllocatedSize(); auto requestedEventPathCount = subscriptionInfo.mEventPaths.AllocatedSize(); if (!imEngine->EnsureResourceForSubscription(subscriptionInfo.mFabricIndex, requestedAttributePathCount, @@ -1656,6 +1671,7 @@ void InteractionModelEngine::ResumeSubscriptionsTimerCallback(System::Layer * ap return; } + ChipLogProgress(InteractionModel, "Resuming subscriptionId %" PRIu32, subscriptionInfo.mSubscriptionId); handler->ResumeSubscription(*imEngine->mpCASESessionMgr, subscriptionInfo); } iterator->Release();