From 0e08d9bad3dd8f406b912e6c6c44ee0559c14603 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 22 Jun 2008 22:07:47 +0200 Subject: [PATCH] src/rrd_daemon.c: pthread_cond_timedwait expects an _absolute_ time, d'oh! --- src/rrd_daemon.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 3af33dc..87ed720 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -252,21 +252,12 @@ static void *queue_thread_main (void *args __attribute__((unused))) /* {{{ */ * something comes in or it's time to do the cache flush. */ if (cache_queue_head == NULL) { - struct timespec timeout; - - timeout.tv_sec = next_flush.tv_sec - now.tv_sec; - if (next_flush.tv_nsec < (1000 * now.tv_usec)) - { - timeout.tv_sec--; - timeout.tv_nsec = 1000000000 + next_flush.tv_nsec - - (1000 * now.tv_usec); - } - else + status = pthread_cond_timedwait (&cache_cond, &cache_lock, &next_flush); + if ((status != 0) && (status != ETIMEDOUT)) { - timeout.tv_nsec = next_flush.tv_nsec - (1000 * now.tv_usec); + RRDD_LOG (LOG_ERR, "queue_thread_main: " + "pthread_cond_timedwait returned %i.", status); } - - pthread_cond_timedwait (&cache_cond, &cache_lock, &timeout); } /* Check if a value has arrived. This may be NULL if we timed out or there -- 2.11.0