Skip to content

Commit

Permalink
Make sure there is only one state that an MTRControllerFactory with n…
Browse files Browse the repository at this point in the history
…o controllers can be in. (#23348)

We don't want to be in different states in the "started no
controllers" and "started one controller and then shut it down" cases.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Apr 11, 2023
1 parent 9d7eb47 commit 2580849
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/darwin/Framework/CHIP/MTRControllerFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ - (BOOL)startup:(MTRControllerFactoryParams *)startupParams
return;
}

// Make sure we don't leave a system state running while we have no
// controllers started. This is working around the fact that a system
// state is brought up live on factory init, and not when it comes time
// to actually start a controller, and does not actually clean itself up
// until its refcount (which starts as 0) goes to 0.
_controllerFactory->RetainSystemState();
_controllerFactory->ReleaseSystemState();

self->_isRunning = YES;
});

Expand Down

0 comments on commit 2580849

Please sign in to comment.