Skip to content
Snippets Groups Projects
Commit a384fa05 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Threads.Condition: Fix wait() with sub-second timeout.

pthread_cond_timedwait() does NOT normalize tv_nsec. A wait with
a tv_sec of zero and a tv_nsec >= 1000000000 seems to give no
wait at all.

Fixes #10070.
parent f01020a0
No related branches found
No related tags found
No related merge requests found
......@@ -296,6 +296,11 @@ PMOD_EXPORT int co_wait_timeout(COND_T *c, PIKE_MUTEX_T *m, long s, long nanos)
ACCURATE_GETTIMEOFDAY(&ct);
timeout.tv_sec = ct.tv_sec + s;
timeout.tv_nsec = ct.tv_usec * 1000 + nanos;
s = timeout.tv_nsec/1000000000;
if (s) {
timeout.tv_sec += s;
timeout.tv_nsec -= s * 1000000000;
}
return pthread_cond_timedwait(c, m, &timeout);
#endif /* HAVE_PTHREAD_COND_RELTIMEDWAIT_NP */
#else /* !POSIX_THREADS */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment