From 4f658f62aeced8b413f0f3bf9f5117897234a120 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 8 Aug 2023 16:29:32 -0400 Subject: [PATCH] Fix cancellation of subscriptions to work correctly. (#28569) * Fix cancellation of subscriptions to work correctly. When a subscription came in with KeepSubscriptions set to false, we would just directly delete the ReadHandlers for the subscriptions not being kept, instead of calling Close(). That meant we skipped deleting subscription persistence data, and also failed to correcly update the reporting engine's round-robin reporting state, which could lead to subscriptions not being serviced fairly. The fix is to just call Close() just like we do for out-of-resource eviction, instead of manually deleting the object. * Fix build issue. --- src/app/InteractionModelEngine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 23aaf9d85d03be..a86dd4b98aed9e 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -615,14 +615,14 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest // Walk through all existing subscriptions and shut down those whose subscriber matches // that which just came in. // - mReadHandlers.ForEachActiveObject([this, apExchangeContext](ReadHandler * handler) { + mReadHandlers.ForEachActiveObject([apExchangeContext](ReadHandler * handler) { if (handler->IsFromSubscriber(*apExchangeContext)) { ChipLogProgress(InteractionModel, "Deleting previous subscription from NodeId: " ChipLogFormatX64 ", FabricIndex: %u", ChipLogValueX64(apExchangeContext->GetSessionHandle()->AsSecureSession()->GetPeerNodeId()), apExchangeContext->GetSessionHandle()->GetFabricIndex()); - mReadHandlers.ReleaseObject(handler); + handler->Close(); } return Loop::Continue;