X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_daemon.c;h=52e9f12ba06301157db4a80ea4dce0164d19d490;hb=a20684ff194feae2de7ea2adfeee8558c9f3d08a;hp=d404e04b40fe2029051c605e11c22aa83c19f787;hpb=e8300a5a1b96f252de0315aa797a187ce2e01f43;p=rrdtool.git diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index d404e04..52e9f12 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -62,7 +62,16 @@ /* * Now for some includes.. */ -#include "rrd.h" /* {{{ */ +/* {{{ */ +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__) && !defined(HAVE_CONFIG_H) +#include "../win32/config.h" +#else +#ifdef HAVE_CONFIG_H +#include "../rrd_config.h" +#endif +#endif + +#include "rrd.h" #include "rrd_client.h" #include @@ -564,6 +573,7 @@ static void wipe_ci_values(cache_item_t *ci, time_t when) static void remove_from_queue(cache_item_t *ci) /* {{{ */ { if (ci == NULL) return; + if ((ci->flags & CI_FLAGS_IN_QUEUE) == 0) return; /* not queued */ if (ci->prev == NULL) cache_queue_head = ci->next; /* reset head */ @@ -625,9 +635,8 @@ static int enqueue_cache_item (cache_item_t *ci, /* {{{ */ if (cache_queue_head == ci) return 0; - /* remove from the double linked list */ - if (ci->flags & CI_FLAGS_IN_QUEUE) - remove_from_queue(ci); + /* remove if further down in queue */ + remove_from_queue(ci); ci->prev = NULL; ci->next = cache_queue_head; @@ -681,20 +690,20 @@ static gboolean tree_callback_flush (gpointer key, gpointer value, /* {{{ */ ci = (cache_item_t *) value; cfd = (callback_flush_data_t *) data; + if (ci->flags & CI_FLAGS_IN_QUEUE) + return FALSE; + if ((ci->last_flush_time <= cfd->abs_timeout) - && ((ci->flags & CI_FLAGS_IN_QUEUE) == 0) && (ci->values_num > 0)) { enqueue_cache_item (ci, TAIL); } else if ((do_shutdown != 0) - && ((ci->flags & CI_FLAGS_IN_QUEUE) == 0) && (ci->values_num > 0)) { enqueue_cache_item (ci, TAIL); } else if (((cfd->now - ci->last_flush_time) >= config_flush_interval) - && ((ci->flags & CI_FLAGS_IN_QUEUE) == 0) && (ci->values_num <= 0)) { char **temp; @@ -1375,7 +1384,6 @@ static int handle_request_update (listen_socket_t *sock, /* {{{ */ { char *file, file_tmp[PATH_MAX]; int values_num = 0; - int bad_timestamps = 0; int status; char orig_buf[CMD_MAX]; @@ -1450,6 +1458,7 @@ static int handle_request_update (listen_socket_t *sock, /* {{{ */ wipe_ci_values(ci, now); ci->flags = CI_FLAGS_IN_TREE; + pthread_cond_init(&ci->flushed, NULL); pthread_mutex_lock(&cache_lock); g_tree_insert (cache_tree, (void *) ci->file, (void *) ci); @@ -1478,18 +1487,17 @@ static int handle_request_update (listen_socket_t *sock, /* {{{ */ stamp = strtol(value, &eostamp, 10); if (eostamp == value || eostamp == NULL || *eostamp != ':') { - ++bad_timestamps; - add_response_info(sock, "Cannot find timestamp in '%s'!\n", value); - continue; + pthread_mutex_unlock(&cache_lock); + return send_response(sock, RESP_ERR, + "Cannot find timestamp in '%s'!\n", value); } else if (stamp <= ci->last_update_stamp) { - ++bad_timestamps; - add_response_info(sock, - "illegal attempt to update using time %ld when" - " last update time is %ld (minimum one second step)\n", - stamp, ci->last_update_stamp); - continue; + pthread_mutex_unlock(&cache_lock); + return send_response(sock, RESP_ERR, + "illegal attempt to update using time %ld when last" + " update time is %ld (minimum one second step)\n", + stamp, ci->last_update_stamp); } else ci->last_update_stamp = stamp; @@ -1524,21 +1532,7 @@ static int handle_request_update (listen_socket_t *sock, /* {{{ */ pthread_mutex_unlock (&cache_lock); if (values_num < 1) - { - /* journal replay mode */ - if (sock == NULL) return RESP_ERR; - - /* if we had only one update attempt, then return the full - error message... try to get the most information out - of the limited error space allowed by the protocol - */ - if (bad_timestamps == 1) - return send_response(sock, RESP_ERR, "%s", sock->wbuf); - else - return send_response(sock, RESP_ERR, - "No values updated (%d bad timestamps).\n", - bad_timestamps); - } + return send_response(sock, RESP_ERR, "No values updated.\n"); else return send_response(sock, RESP_OK, "errors, enqueued %i value(s).\n", values_num);