Skip to content

Commit

Permalink
Fixing deadlock, and not cleaning up on purpose now (project-chip#35982)
Browse files Browse the repository at this point in the history
* Fixing deadlock, and not cleaning up on purpose now

* Adding this log back

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and yyzhong-g committed Dec 11, 2024
1 parent e265d98 commit 50f9305
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,7 @@
static bool sExitHandlerRegistered = false;
static void ShutdownOnExit()
{
// Depending on the structure of the software, this code might execute *after* the main autorelease pool has exited.
// Therefore, it needs to be enclosed in its own autorelease pool.
@autoreleasepool {
MTR_LOG("ShutdownOnExit invoked on exit");
[[MTRDeviceControllerFactory sharedInstance] stopControllerFactory];
}
// Don't do anything here, period
}

@interface MTRDeviceControllerFactoryParams ()
Expand Down Expand Up @@ -441,8 +436,8 @@ - (void)stopControllerFactory
{
[self _assertCurrentQueueIsNotMatterQueue];

while ([_controllers count] != 0) {
[_controllers[0] shutdown];
for (MTRDeviceController * controller in [_controllers copy]) {
[controller shutdown];
}

dispatch_sync(_chipWorkQueue, ^{
Expand Down
6 changes: 4 additions & 2 deletions src/darwin/Framework/CHIP/MTRDevice_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID

@try {
[[xpcConnection remoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) {
MTR_LOG_ERROR("Error: %@", error);
MTR_LOG_ERROR("Invoke error: %@", error);
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
}] deviceController:[[self deviceController] uniqueIdentifier]
nodeID:[self nodeID]
invokeCommandWithEndpointID:endpointID
Expand All @@ -263,7 +264,8 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
serverSideProcessingTimeout:serverSideProcessingTimeout
completion:completion];
} @catch (NSException * exception) {
MTR_LOG_ERROR("Exception sending XPC messsage: %@", exception);
MTR_LOG_ERROR("Exception sending XPC message: %@", exception);
completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeGeneralError userInfo:nil]);
}
}

Expand Down

0 comments on commit 50f9305

Please sign in to comment.