Skip to content

Commit 3160951

Browse files
Aidan63Aidan Lee
andauthored
Add missing win32 semaphore free zone exit call (#1316)
* Add missing free zone exit call * Check errno --------- Co-authored-by: Aidan Lee <aidan.lee@evcam.com>
1 parent bda3160 commit 3160951

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/hx/thread/CountingSemaphore.posix.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,22 @@ bool hx::thread::CountingSemaphore_obj::tryAcquire(Null<double> timeout)
7070
t.tv_sec = tv.tv_sec + idelta + idelta2;
7171
t.tv_nsec = (long)delta;
7272

73-
switch (sem_timedwait(&impl->semaphore, &t))
73+
if (0 == sem_timedwait(&impl->semaphore, &t))
7474
{
75-
case 0:
7675
hx::ExitGCFreeZone();
7776
return true;
78-
case ETIMEDOUT:
79-
hx::ExitGCFreeZone();
80-
return false;
81-
default:
77+
}
78+
else
79+
{
8280
hx::ExitGCFreeZone();
83-
return hx::Throw(HX_CSTRING("Failed to wait for semaphore"));
81+
if (errno == ETIMEDOUT)
82+
{
83+
return false;
84+
}
85+
else
86+
{
87+
return hx::Throw(HX_CSTRING("Failed to wait for semaphore"));
88+
}
8489
}
8590
}
8691
}

src/hx/thread/CountingSemaphore.win32.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ void hx::thread::CountingSemaphore_obj::acquire()
3434
hx::ExitGCFreeZone();
3535
hx::Throw(HX_CSTRING("Failed to wait for semaphore"));
3636
}
37+
38+
hx::ExitGCFreeZone();
3739
}
3840

3941
void hx::thread::CountingSemaphore_obj::release()

0 commit comments

Comments
 (0)