Skip to content

Commit

Permalink
Make sure we create semaphore before we try to use it. (project-chip#…
Browse files Browse the repository at this point in the history
…22385)

The semaphore will get signaled by the event loop we spin up.  We
should make sure it exists before we spin up that event loop.
  • Loading branch information
bzbarsky-apple authored and isiu-apple committed Sep 16, 2022
1 parent 36e3dd5 commit b8b9215
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/platform/Darwin/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@ CHIP_ERROR PlatformManagerImpl::_StopEventLoopTask()

void PlatformManagerImpl::_RunEventLoop()
{
mRunLoopSem = dispatch_semaphore_create(0);

_StartEventLoopTask();

//
// Block on the semaphore till we're signalled to stop by
// _StopEventLoopTask()
//
mRunLoopSem = dispatch_semaphore_create(0);
dispatch_semaphore_wait(mRunLoopSem, DISPATCH_TIME_FOREVER);
dispatch_release(mRunLoopSem);
mRunLoopSem = nullptr;
Expand Down

0 comments on commit b8b9215

Please sign in to comment.