mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-12 17:12:46 +00:00
problem: pthread_cond_timedwait sometimes fail with EINVAL
Solution: fix rounding error and assert if the clock_gettime fails
This commit is contained in:
parent
d78ecb8dc8
commit
fb852fd3e7
@ -259,13 +259,14 @@ class condition_variable_t
|
|||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_nsec = 0;
|
timeout.tv_nsec = 0;
|
||||||
#else
|
#else
|
||||||
clock_gettime (CLOCK_MONOTONIC, &timeout);
|
rc = clock_gettime (CLOCK_MONOTONIC, &timeout);
|
||||||
|
posix_assert (rc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timeout.tv_sec += timeout_ / 1000;
|
timeout.tv_sec += timeout_ / 1000;
|
||||||
timeout.tv_nsec += (timeout_ % 1000) * 1000000;
|
timeout.tv_nsec += (timeout_ % 1000) * 1000000;
|
||||||
|
|
||||||
if (timeout.tv_nsec > 1000000000) {
|
if (timeout.tv_nsec >= 1000000000) {
|
||||||
timeout.tv_sec++;
|
timeout.tv_sec++;
|
||||||
timeout.tv_nsec -= 1000000000;
|
timeout.tv_nsec -= 1000000000;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user