# define __attribute__(x) /**/
#endif
-#if 0
-/* FIXME: I don't want to declare strdup myself! */
-extern char *strdup (const char *s);
-#endif
-
/*
* Types
*/
*/
static int enqueue_cache_item (cache_item_t *ci) /* {{{ */
{
- RRDD_LOG (LOG_DEBUG, "handle_request_update: Adding %s to the update queue.",
+ RRDD_LOG (LOG_DEBUG, "enqueue_cache_item: Adding %s to the update queue.",
ci->file);
if (ci == NULL)
assert (ci->next == NULL);
+ if (ci->values_num == 0)
+ return (0);
+
if (cache_queue_tail == NULL)
cache_queue_head = ci;
else
* 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
} /* }}} void *queue_thread_main */
static int handle_request_update (int fd, /* {{{ */
- char *buffer, int buffer_size)
+ char *buffer, int buffer_size __attribute__((unused)))
{
char *file;
char *value;
now = time (NULL);
- RRDD_LOG (LOG_DEBUG, "handle_request_update (%i, %p, %i)",
- fd, (void *) buffer, buffer_size);
-
buffer_ptr = buffer;
file = buffer_ptr;
char buffer[4096];
int buffer_size;
- RRDD_LOG (LOG_DEBUG, "handle_request (%i)", fd);
-
buffer_size = read (fd, buffer, sizeof (buffer));
if (buffer_size < 1)
{
fd = *((int *) args);
- RRDD_LOG (LOG_DEBUG, "connection_thread_main: Adding myself to "
- "connetion_threads[]..");
pthread_mutex_lock (&connetion_threads_lock);
{
pthread_t *temp;
}
}
pthread_mutex_unlock (&connetion_threads_lock);
- RRDD_LOG (LOG_DEBUG, "connection_thread_main: done");
while (do_shutdown == 0)
{
if ((pollfd.revents & POLLHUP) != 0) /* normal shutdown */
{
- RRDD_LOG (LOG_DEBUG, "connection_thread_main: "
- "poll(2) returned POLLHUP.");
close (fd);
break;
}
continue;
}
- RRDD_LOG (LOG_DEBUG, "listen_thread_main: accept(2) returned fd #%i.",
- *client_sd);
-
status = pthread_create (&tid, /* attr = */ NULL, connection_thread_main,
/* args = */ (void *) client_sd);
if (status != 0)
free (client_sd);
continue;
}
-
- RRDD_LOG (LOG_DEBUG, "listen_thread_main: pthread_create succeeded: "
- "tid = %lu",
- *((unsigned long *) &tid));
} /* for (pollfds_num) */
} /* while (do_shutdown == 0) */