X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_client.c;h=8e606640455eaa01b47d6f4ff7c7771c2b746a34;hp=44d4d603b7df5a11208e40f0375389cc383f3c8b;hb=f0a82ae15cafb6ad47ea0c9f74754820e92e2078;hpb=afb590e6dbc73ed9e1eb7015071cead52e3692d3 diff --git a/src/rrd_client.c b/src/rrd_client.c index 44d4d60..8e60664 100644 --- a/src/rrd_client.c +++ b/src/rrd_client.c @@ -518,6 +518,7 @@ int rrdc_update (const char *filename, int values_num, /* {{{ */ rrdc_response_t *res; int status; int i; + char file_path[PATH_MAX]; memset (buffer, 0, sizeof (buffer)); buffer_ptr = &buffer[0]; @@ -527,6 +528,10 @@ int rrdc_update (const char *filename, int values_num, /* {{{ */ if (status != 0) return (ENOBUFS); + /* change to absolute path for rrdcached */ + if (*filename != '/' && realpath(filename, file_path) != NULL) + filename = file_path; + status = buffer_add_string (filename, &buffer_ptr, &buffer_free); if (status != 0) return (ENOBUFS); @@ -562,6 +567,7 @@ int rrdc_flush (const char *filename) /* {{{ */ size_t buffer_size; rrdc_response_t *res; int status; + char file_path[PATH_MAX]; if (filename == NULL) return (-1); @@ -574,6 +580,10 @@ int rrdc_flush (const char *filename) /* {{{ */ if (status != 0) return (ENOBUFS); + /* change to absolute path for rrdcached */ + if (*filename != '/' && realpath(filename, file_path) != NULL) + filename = file_path; + status = buffer_add_string (filename, &buffer_ptr, &buffer_free); if (status != 0) return (ENOBUFS); @@ -606,11 +616,21 @@ int rrdc_flush_if_daemon (const char *opt_daemon, const char *filename) /* {{{ * if (rrdc_is_connected(opt_daemon)) { + rrd_clear_error(); status = rrdc_flush (filename); - if (status != 0) + + if (status != 0 && !rrd_test_error()) { - rrd_set_error ("rrdc_flush (%s) failed with status %i.", - filename, status); + if (status > 0) + { + rrd_set_error("rrdc_flush (%s) failed: %s", + filename, rrd_strerror(status)); + } + else if (status < 0) + { + rrd_set_error("rrdc_flush (%s) failed with status %i.", + filename, status); + } } } /* if (rrdc_is_connected(..)) */ @@ -741,7 +761,7 @@ void rrdc_stats_free (rrdc_stats_t *ret_stats) /* {{{ */ if (this->name != NULL) { - free (this->name); + free ((char *)this->name); this->name = NULL; } free (this);