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

Make removeDevice drop the subscription for an MTRDevice. #33767

Merged
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
15 changes: 12 additions & 3 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,18 @@ - (void)invalidate
// attempt, since we now have no delegate.
_reattemptingSubscription = NO;

// We do not change _internalDeviceState here, because we might still have a
// subscription. In that case, _internalDeviceState will update when the
// subscription is actually terminated.
[_deviceController asyncDispatchToMatterQueue:^{
// Destroy the read client and callback (has to happen on the Matter
// queue, to avoid deleting objects that are being referenced), to
// tear down the subscription. We will get no more callbacks from
// the subscrption after this point.
std::lock_guard lock(self->_lock);
self->_currentReadClient = nullptr;
self->_currentSubscriptionCallback = nullptr;

[self _changeInternalState:MTRInternalDeviceStateUnsubscribed];
}
errorHandler:nil];

[self _stopConnectivityMonitoring];

Expand Down
Loading