From: Peter Stamfest Date: Thu, 4 Sep 2014 06:54:46 +0000 (+0200) Subject: Make rrd create work via the caching daemon X-Git-Tag: v1.5.0-rc1~42^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31e8869655d614c1068b0423fec0a95336305a76;p=thirdparty%2Frrdtool-1.x.git Make rrd create work via the caching daemon --- diff --git a/src/rrd_client.c b/src/rrd_client.c index 58a3d5b8..c53c1ffd 100644 --- a/src/rrd_client.c +++ b/src/rrd_client.c @@ -1248,24 +1248,26 @@ int rrdc_create_r2(const char *filename, /* {{{ */ } status = buffer_add_string (filename, &buffer_ptr, &buffer_free); - status = buffer_add_string ("-b", &buffer_ptr, &buffer_free); - status = buffer_add_ulong (last_up, &buffer_ptr, &buffer_free); + if (last_up >= 0) { + status = buffer_add_string ("-b", &buffer_ptr, &buffer_free); + status = buffer_add_ulong (last_up, &buffer_ptr, &buffer_free); + } status = buffer_add_string ("-s", &buffer_ptr, &buffer_free); status = buffer_add_ulong (pdp_step, &buffer_ptr, &buffer_free); if(no_overwrite) { status = buffer_add_string ("-O", &buffer_ptr, &buffer_free); } - + if (sources != NULL) { for (const char **p = sources ; *p ; p++) { - buffer_add_string ("-r", &buffer_ptr, &buffer_free); - buffer_add_string (*p, &buffer_ptr, &buffer_free); + status = buffer_add_string ("-r", &buffer_ptr, &buffer_free); + status = buffer_add_string (*p, &buffer_ptr, &buffer_free); } } if (template != NULL) { - buffer_add_string ("-t", &buffer_ptr, &buffer_free); - buffer_add_string (template, &buffer_ptr, &buffer_free); + status = buffer_add_string ("-t", &buffer_ptr, &buffer_free); + status = buffer_add_string (template, &buffer_ptr, &buffer_free); } if (status != 0) diff --git a/src/rrd_create.c b/src/rrd_create.c index 5510b173..a155e3ad 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -779,7 +779,7 @@ int rrd_create_r2( rrd_close(tf); } - if (rrd.stat_head->pdp_step == 0) { + if (rrd.stat_head->pdp_step <= 0) { rrd.stat_head->pdp_step = 300; } @@ -876,6 +876,8 @@ int rrd_create_r2( rc = rrd_init_data(&rrd); if (rc != 0) goto done; + rc = -1; // reset rc to default error state + if (sources != NULL) { time_t sources_latest_last_up = 0; diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 81535ef5..4a611e3d 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -1917,8 +1917,8 @@ static int handle_request_create (HANDLER_PROTO) /* {{{ */ int sources_length = 0; char *template = NULL; int status; - unsigned long step = 300; - time_t last_up = time(NULL)-10; + unsigned long step = 0; + time_t last_up = -1; int no_overwrite = opt_no_overwrite; int rc = -1; @@ -1988,8 +1988,12 @@ static int handle_request_create (HANDLER_PROTO) /* {{{ */ rc = send_response(sock, RESP_ERR, "Cannot allocate memory\n"); goto done; } + + flush_file(tok); + sources[sources_length++] = tok; - sources[sources_length + 1] = NULL; + sources[sources_length] = NULL; + continue; } if( ! strncmp(tok,"-t",2) ) { @@ -1998,6 +2002,8 @@ static int handle_request_create (HANDLER_PROTO) /* {{{ */ rc = syntax_error(sock,cmd); goto done; } + flush_file(tok); + template = tok; continue; } @@ -2010,11 +2016,7 @@ static int handle_request_create (HANDLER_PROTO) /* {{{ */ rc = syntax_error(sock,cmd); goto done; } - if(step<1) { - rc = send_response(sock, RESP_ERR, "The step size cannot be less than 1 second.\n"); - goto done; - } - if (last_up < 3600 * 24 * 365 * 10) { + if (last_up != -1 && last_up < 3600 * 24 * 365 * 10) { rc = send_response(sock, RESP_ERR, "The first entry must be after 1980.\n"); goto done; }