src/rrd_daemon.c: pthread_cond_timedwait expects an _absolute_ time, d'oh!
authorFlorian Forster <octo@leeloo.home.verplant.org>
Sun, 22 Jun 2008 20:07:47 +0000 (22:07 +0200)
committerFlorian Forster <octo@leeloo.home.verplant.org>
Sun, 22 Jun 2008 20:07:47 +0000 (22:07 +0200)
src/rrd_daemon.c

index 3af33dc..87ed720 100644 (file)
@@ -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