rthreads: fix bug in scond_wait_timeout

Handle nanosecond count overflowing a full second
This commit is contained in:
Brian Koropoff 2017-10-15 14:38:19 -07:00
parent 9addca1d62
commit 5e386f0149

View File

@ -808,6 +808,12 @@ bool scond_wait_timeout(scond_t *cond, slock_t *lock, int64_t timeout_us)
now.tv_sec += seconds;
now.tv_nsec += remainder * INT64_C(1000);
while (now.tv_nsec >= INT64_C(1000000000))
{
now.tv_sec++;
now.tv_nsec -= INT64_C(1000000000);
}
ret = pthread_cond_timedwait(&cond->cond, &lock->lock, &now);
return (ret == 0);
#endif