* 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