diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-12-07 16:07:48 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-12-07 16:07:48 +0100 |
commit | 1670ee5aba09e240580b68a727dc328880e8df13 (patch) | |
tree | e82527ef18f084371f7b55bf23ef718de85c5b82 | |
parent | e7dfd40dc37ddf8779cbcdf2afa54da89b4776d0 (diff) | |
download | serenity-1670ee5aba09e240580b68a727dc328880e8df13.zip |
LibPthread: Condition variables should use CLOCK_MONOTONIC by default
It's the only clock we have at the moment, so it's a logical choice :^)
-rw-r--r-- | Libraries/LibPthread/pthread.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Libraries/LibPthread/pthread.cpp b/Libraries/LibPthread/pthread.cpp index 246e2abdc5..637ebab3bd 100644 --- a/Libraries/LibPthread/pthread.cpp +++ b/Libraries/LibPthread/pthread.cpp @@ -395,7 +395,7 @@ struct WaitNode : public InlineLinkedListNode<WaitNode> { struct ConditionVariable { InlineLinkedList<WaitNode> waiters; - clockid_t clock; + clockid_t clock { CLOCK_MONOTONIC }; }; int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) @@ -450,8 +450,10 @@ int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const s condvar.waiters.append(&node); while (node.waiting) { struct timespec now; - if (clock_gettime(condvar.clock, &now) < 0) + if (clock_gettime(condvar.clock, &now) < 0) { + dbgprintf("pthread_cond_timedwait: clock_gettime() failed\n"); return errno; + } if ((abstime->tv_sec < now.tv_sec) || (abstime->tv_sec == now.tv_sec && abstime->tv_nsec <= now.tv_nsec)) { return ETIMEDOUT; } |