Skip to content

Commit

Permalink
Fix chip-tool cleanup of subscription clients. (#21600)
Browse files Browse the repository at this point in the history
We were doing it from the wrong thread in some cases.

Fixes #21599
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Jan 9, 2024
1 parent 2f504d5 commit 9990497
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,14 @@ class SubscribeCommand : public ReportCommand

void OnDone(chip::app::ReadClient * aReadClient) override
{
InteractionModelReports::CleanupReadClient(aReadClient);

if (!mSubscriptionEstablished)
{
InteractionModelReports::CleanupReadClient(aReadClient);
SetCommandExitStatus(mError);
}

// else we must be getting here from Cleanup(), which means we have
// already done our exit status thing, and have done the ReadClient
// cleanup.
// already done our exit status thing.
}

void Shutdown() override
Expand All @@ -161,7 +160,10 @@ class SubscribeCommand : public ReportCommand
ReportCommand::Shutdown();
}

bool DeferInteractiveCleanup() override { return mSubscriptionEstablished; }
// For subscriptions we always defer interactive cleanup. Either our
// ReadClients will terminate themselves (in which case they will be removed
// from our list anyway), or they should hang around until shutdown.
bool DeferInteractiveCleanup() override { return true; }

private:
bool mSubscriptionEstablished = false;
Expand Down

0 comments on commit 9990497

Please sign in to comment.