Merge pull request #3974 from somdoron/pthread_cond_timedwait

problem: pthread_cond_timedwait sometimes fail with EINVAL
This commit is contained in:
Luca Boccassi 2020-06-28 17:36:26 +01:00 committed by GitHub
commit c8e3dfca90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -259,13 +259,14 @@ class condition_variable_t
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
#else
clock_gettime (CLOCK_MONOTONIC, &timeout);
rc = clock_gettime (CLOCK_MONOTONIC, &timeout);
posix_assert (rc);
#endif
timeout.tv_sec += timeout_ / 1000;
timeout.tv_nsec += (timeout_ % 1000) * 1000000;
if (timeout.tv_nsec > 1000000000) {
if (timeout.tv_nsec >= 1000000000) {
timeout.tv_sec++;
timeout.tv_nsec -= 1000000000;
}