Skip to content

Commit a629204

Browse files
Fixing deadlock, and not cleaning up on purpose now (project-chip#35982)
* Fixing deadlock, and not cleaning up on purpose now * Adding this log back * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent af3727b commit a629204

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm

+3-8
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@
7373
static bool sExitHandlerRegistered = false;
7474
static void ShutdownOnExit()
7575
{
76-
// Depending on the structure of the software, this code might execute *after* the main autorelease pool has exited.
77-
// Therefore, it needs to be enclosed in its own autorelease pool.
78-
@autoreleasepool {
79-
MTR_LOG("ShutdownOnExit invoked on exit");
80-
[[MTRDeviceControllerFactory sharedInstance] stopControllerFactory];
81-
}
76+
// Don't do anything here, period
8277
}
8378

8479
@interface MTRDeviceControllerFactoryParams ()
@@ -441,8 +436,8 @@ - (void)stopControllerFactory
441436
{
442437
[self _assertCurrentQueueIsNotMatterQueue];
443438

444-
while ([_controllers count] != 0) {
445-
[_controllers[0] shutdown];
439+
for (MTRDeviceController * controller in [_controllers copy]) {
440+
[controller shutdown];
446441
}
447442

448443
dispatch_sync(_chipWorkQueue, ^{

src/darwin/Framework/CHIP/MTRDevice_XPC.mm

+4-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
250250

251251
@try {
252252
[[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
253-
MTR_LOG_ERROR("Error: %@", error);
253+
MTR_LOG_ERROR("Invoke error: %@", error);
254+
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
254255
}] deviceController:[[self deviceController] uniqueIdentifier]
255256
nodeID:[self nodeID]
256257
invokeCommandWithEndpointID:endpointID
@@ -263,7 +264,8 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
263264
serverSideProcessingTimeout:serverSideProcessingTimeout
264265
completion:completion];
265266
} @catch (NSException * exception) {
266-
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception);
267+
MTR_LOG_ERROR("Exception sending XPC message: %@", exception);
268+
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
267269
}
268270
}
269271

0 commit comments

Comments
 (0)