diff options
Diffstat (limited to 'src/Platform/Posix/Condition.c')
| -rw-r--r-- | src/Platform/Posix/Condition.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Platform/Posix/Condition.c b/src/Platform/Posix/Condition.c index 3fb5041..67715b3 100644 --- a/src/Platform/Posix/Condition.c +++ b/src/Platform/Posix/Condition.c @@ -43,8 +43,14 @@ int BH_ConditionWaitFor(BH_Condition *condition, { struct timespec ts; - ts.tv_sec = timeout / 1000; - ts.tv_nsec = (timeout - ts.tv_sec * 1000) * 1000000; + /* Calculate absoulute time for timed wait */ + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += timeout / 1000; + ts.tv_nsec += (timeout % 1000) * 1000000; + while (ts.tv_nsec >= 1000000000) { + ts.tv_nsec -= 1000000000; + ts.tv_sec += 1; + } switch (pthread_cond_timedwait(&condition->handle, &mutex->handle, &ts)) { |
