Skip to content

Commit

Permalink
Fix cancellation of subscriptions to work correctly. (#28569)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
bzbarsky-apple authored Aug 8, 2023
1 parent 732f797 commit 4f658f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4f658f6

Please sign in to comment.