summaryrefslogtreecommitdiff
path: root/sem_timedwait.c
diff options
context:
space:
mode:
Diffstat (limited to 'sem_timedwait.c')
-rw-r--r--sem_timedwait.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sem_timedwait.c b/sem_timedwait.c
index e374006..e7fa55c 100644
--- a/sem_timedwait.c
+++ b/sem_timedwait.c
@@ -189,7 +189,15 @@ sem_timedwait (sem_t * sem, const struct timespec *abstime)
#else /* NEED_SEM */
- result = (pthreadCancelableTimedWait ((*sem)->sem, milliseconds));
+ if (InterlockedDecrement((LPLONG) &(*sem)->value) < 0)
+ {
+ /* Must wait */
+ result = pthreadCancelableTimedWait ((*sem)->sem, milliseconds);
+ if (result != 0)
+ {
+ (void) InterlockedIncrement((LPLONG) &(*sem)->value);
+ }
+ }
#endif