From 10089128dc01ef24153d5477b0a132da4b0f2696 Mon Sep 17 00:00:00 2001 From: Jeff Tung <100387939+jtung-apple@users.noreply.github.com> Date: Sun, 12 May 2024 20:58:39 -0700 Subject: [PATCH] [Darwin] Fix MTRDeviceConnectivityMonitor DNSServiceRefDeallocate call on the correct queue (#33410) --- .../Framework/CHIP/MTRDeviceConnectivityMonitor.mm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDeviceConnectivityMonitor.mm b/src/darwin/Framework/CHIP/MTRDeviceConnectivityMonitor.mm index 229d95d9206bc1..80ad6f80d5be2b 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceConnectivityMonitor.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceConnectivityMonitor.mm @@ -271,8 +271,11 @@ - (void)_stopMonitoring - (void)stopMonitoring { - MTR_LOG_INFO("%@ stop connectivity monitoring for %@", self, _instanceName); - std::lock_guard lock(sConnectivityMonitorLock); - [self _stopMonitoring]; + // DNSServiceRefDeallocate must be called on the same queue set on the shared connection. + dispatch_async(sSharedResolverQueue, ^{ + MTR_LOG_INFO("%@ stop connectivity monitoring for %@", self, self->_instanceName); + std::lock_guard lock(sConnectivityMonitorLock); + [self _stopMonitoring]; + }); } @end