diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-09-27 12:09:57 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-01-14 11:09:52 -0500 |
commit | d69717f61bd9ab4e0a6097f0201bd02fc96f88eb (patch) | |
tree | f1517c624539319a26c86691eb1f4a07992b0650 /src/common/compat_pthreads.c | |
parent | 9fdc0d059456146722dc81f2b58672b533a2bb71 (diff) | |
download | tor-d69717f61bd9ab4e0a6097f0201bd02fc96f88eb.tar.gz tor-d69717f61bd9ab4e0a6097f0201bd02fc96f88eb.zip |
Use correct (absolute) time for pthread_cond_timedwait
Diffstat (limited to 'src/common/compat_pthreads.c')
-rw-r--r-- | src/common/compat_pthreads.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c index 8d3c60917a..59834270a3 100644 --- a/src/common/compat_pthreads.c +++ b/src/common/compat_pthreads.c @@ -199,9 +199,12 @@ tor_cond_wait(tor_cond_t *cond, tor_mutex_t *mutex, const struct timeval *tv) return pthread_cond_wait(&cond->cond, &mutex->mutex) ? -1 : 0; } else { struct timespec ts; + struct timeval tvnow, tvsum; int r; - ts.tv_sec = tv->tv_sec; - ts.tv_nsec = tv->tv_usec * 1000; + gettimeofday(&tvnow, NULL); + timeradd(tv, &tvnow, &tvsum); + ts.tv_sec = tvsum.tv_sec; + ts.tv_nsec = tvsum.tv_usec * 1000; r = pthread_cond_timedwait(&cond->cond, &mutex->mutex, &ts); if (r == 0) return 0; |