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

[Darwin] MTRBaseSubscriptionCallback mInterimReportBlock should be cancelled and nil-ed sooner for OnError case #29500

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/darwin/Framework/CHIP/MTRBaseSubscriptionCallback.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
// Reports attribute and event data if any exists
void MTRBaseSubscriptionCallback::ReportData()
{
// At data reporting time, nil out scheduled or currently running interimReportBlock
if (mInterimReportBlock) {
dispatch_block_cancel(mInterimReportBlock); // no-op when running from mInterimReportBlock
mInterimReportBlock = nil;
}

__block NSArray * attributeReports = mAttributeReports;
mAttributeReports = nil;
auto attributeCallback = mAttributeReportCallback;
Expand All @@ -59,7 +65,6 @@
}

mInterimReportBlock = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS, ^{
mInterimReportBlock = nil;
ReportData();
// Allocate reports arrays to continue accumulation
mAttributeReports = [NSMutableArray new];
Expand All @@ -71,10 +76,6 @@

void MTRBaseSubscriptionCallback::OnReportEnd()
{
if (mInterimReportBlock) {
dispatch_block_cancel(mInterimReportBlock);
mInterimReportBlock = nil;
}
ReportData();
if (mReportEndHandler) {
mReportEndHandler();
Expand Down
Loading