summaryrefslogtreecommitdiff
path: root/src/thread
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/PosixCond.hxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/thread/PosixCond.hxx b/src/thread/PosixCond.hxx
index 73dbe0218..4e1988ece 100644
--- a/src/thread/PosixCond.hxx
+++ b/src/thread/PosixCond.hxx
@@ -79,6 +79,11 @@ public:
struct timespec ts;
ts.tv_sec = now.tv_sec + timeout_ms / 1000;
ts.tv_nsec = (now.tv_usec + (timeout_ms % 1000) * 1000) * 1000;
+ // Keep tv_nsec < 1E9 to prevent return of EINVAL
+ if (ts.tv_nsec >= 1000000000) {
+ ts.tv_nsec -= 1000000000;
+ ts.tv_sec++;
+ }
return pthread_cond_timedwait(&cond, &mutex.mutex, &ts) == 0;
}