X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_daemon.c;h=273714418ce0a2828e558f4291e6173c65dfca23;hp=a2001359e158bb1e92852d53369163f2fc571f41;hb=7af26ea5c6f5e094e7c02dc47ceb0f87f5f2af48;hpb=c265653b4507e0af5333c9ce51cd4d7420266436 diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index a200135..2737144 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -188,7 +188,7 @@ struct cache_item_s size_t values_num; /* number of valid pointers */ size_t values_alloc; /* number of allocated pointers */ time_t last_flush_time; - time_t last_update_stamp; + double last_update_stamp; #define CI_FLAGS_IN_TREE (1<<0) #define CI_FLAGS_IN_QUEUE (1<<1) int flags; @@ -219,9 +219,7 @@ typedef struct { size_t files_num; } journal_set; -/* max length of socket command or response */ -#define CMD_MAX 4096 -#define RBUF_SIZE (CMD_MAX*2) +#define RBUF_SIZE (RRD_CMD_MAX*2) /* * Variables @@ -543,7 +541,7 @@ static int add_to_wbuf(listen_socket_t *sock, char *str, size_t len) /* {{{ */ static int add_response_info(listen_socket_t *sock, char *fmt, ...) /* {{{ */ { va_list argp; - char buffer[CMD_MAX]; + char buffer[RRD_CMD_MAX]; int len; if (JOURNAL_REPLAY(sock)) return 0; @@ -588,7 +586,7 @@ static int send_response (listen_socket_t *sock, response_code rc, char *fmt, ...) /* {{{ */ { va_list argp; - char buffer[CMD_MAX]; + char buffer[RRD_CMD_MAX]; int lines; ssize_t wrote; int rclen, len; @@ -1327,13 +1325,13 @@ static int handle_request_update (HANDLER_PROTO) /* {{{ */ char *file, file_tmp[PATH_MAX]; int values_num = 0; int status; - char orig_buf[CMD_MAX]; + char orig_buf[RRD_CMD_MAX]; cache_item_t *ci; /* save it for the journal later */ if (!JOURNAL_REPLAY(sock)) - strncpy(orig_buf, buffer, buffer_size); + strncpy(orig_buf, buffer, min(RRD_CMD_MAX,buffer_size)); status = buffer_get_field (&buffer, &buffer_size, &file); if (status != 0) @@ -1424,7 +1422,7 @@ static int handle_request_update (HANDLER_PROTO) /* {{{ */ while (buffer_size > 0) { char *value; - time_t stamp; + double stamp; char *eostamp; status = buffer_get_field (&buffer, &buffer_size, &value); @@ -1434,8 +1432,9 @@ static int handle_request_update (HANDLER_PROTO) /* {{{ */ break; } - /* make sure update time is always moving forward */ - stamp = strtol(value, &eostamp, 10); + /* make sure update time is always moving forward. We use double here since + update does support subsecond precision for timestamps ... */ + stamp = strtod(value, &eostamp); if (eostamp == value || eostamp == NULL || *eostamp != ':') { pthread_mutex_unlock(&cache_lock); @@ -1446,8 +1445,8 @@ static int handle_request_update (HANDLER_PROTO) /* {{{ */ { 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", + "illegal attempt to update using time %lf when last" + " update time is %lf (minimum one second step)\n", stamp, ci->last_update_stamp); } else @@ -2204,7 +2203,7 @@ static int handle_request_help (HANDLER_PROTO) /* {{{ */ if (help && (help->syntax || help->help)) { - char tmp[CMD_MAX]; + char tmp[RRD_CMD_MAX]; snprintf(tmp, sizeof(tmp)-1, "Help for %s\n", help->cmd); resp_txt = tmp; @@ -2439,7 +2438,7 @@ static int journal_replay (const char *file) /* {{{ */ int entry_cnt = 0; int fail_cnt = 0; uint64_t line = 0; - char entry[CMD_MAX]; + char entry[RRD_CMD_MAX]; time_t now; if (file == NULL) return 0; @@ -2655,7 +2654,7 @@ static void *connection_thread_main (void *args) /* {{{ */ getting overwritten by another thread. */ struct request_info req; - request_init(&req, RQ_DAEMON, "rrdcache\0", RQ_FILE, fd, NULL ); + request_init(&req, RQ_DAEMON, "rrdcached\0", RQ_FILE, fd, NULL ); fromhost(&req); if(!hosts_access(&req)) { RRDD_LOG(LOG_INFO, "refused connection from %s", eval_client(&req));