Skip to content

Commit 05172d2

Browse files
Make sure we create semaphore before we try to use it. (#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.
1 parent ba8a495 commit 05172d2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/platform/Darwin/PlatformManagerImpl.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ CHIP_ERROR PlatformManagerImpl::_StopEventLoopTask()
119119

120120
void PlatformManagerImpl::_RunEventLoop()
121121
{
122+
mRunLoopSem = dispatch_semaphore_create(0);
123+
122124
_StartEventLoopTask();
123125

124126
//
125127
// Block on the semaphore till we're signalled to stop by
126128
// _StopEventLoopTask()
127129
//
128-
mRunLoopSem = dispatch_semaphore_create(0);
129130
dispatch_semaphore_wait(mRunLoopSem, DISPATCH_TIME_FOREVER);
130131
dispatch_release(mRunLoopSem);
131132
mRunLoopSem = nullptr;

0 commit comments

Comments
 (0)