projects
/
rrdtool.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix from alex
[rrdtool.git]
/
src
/
rrd_client.c
diff --git
a/src/rrd_client.c
b/src/rrd_client.c
index
7fa9817
..
8e60664
100644
(file)
--- a/
src/rrd_client.c
+++ b/
src/rrd_client.c
@@
-212,6
+212,8
@@
static int response_read (rrdc_response_t **ret_response) /* {{{ */
if (ret->status <= 0)
{
if (ret->status <= 0)
{
+ if (ret->status < 0)
+ rrd_set_error("rrdcached: %s", ret->message);
*ret_response = ret;
return (0);
}
*ret_response = ret;
return (0);
}
@@
-266,6
+268,8
@@
static int request (const char *buffer, size_t buffer_size, /* {{{ */
{
close_connection ();
pthread_mutex_unlock (&lock);
{
close_connection ();
pthread_mutex_unlock (&lock);
+ rrd_set_error("request: socket error (%d) while talking to rrdcached",
+ status);
return (-1);
}
fflush (sh);
return (-1);
}
fflush (sh);
@@
-276,7
+280,11
@@
static int request (const char *buffer, size_t buffer_size, /* {{{ */
pthread_mutex_unlock (&lock);
if (status != 0)
pthread_mutex_unlock (&lock);
if (status != 0)
+ {
+ if (status < 0)
+ rrd_set_error("request: internal error while talking to rrdcached");
return (status);
return (status);
+ }
*ret_response = res;
return (0);
*ret_response = res;
return (0);
@@
-510,6
+518,7
@@
int rrdc_update (const char *filename, int values_num, /* {{{ */
rrdc_response_t *res;
int status;
int i;
rrdc_response_t *res;
int status;
int i;
+ char file_path[PATH_MAX];
memset (buffer, 0, sizeof (buffer));
buffer_ptr = &buffer[0];
memset (buffer, 0, sizeof (buffer));
buffer_ptr = &buffer[0];
@@
-519,6
+528,10
@@
int rrdc_update (const char *filename, int values_num, /* {{{ */
if (status != 0)
return (ENOBUFS);
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);
status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
if (status != 0)
return (ENOBUFS);
@@
-554,6
+567,7
@@
int rrdc_flush (const char *filename) /* {{{ */
size_t buffer_size;
rrdc_response_t *res;
int status;
size_t buffer_size;
rrdc_response_t *res;
int status;
+ char file_path[PATH_MAX];
if (filename == NULL)
return (-1);
if (filename == NULL)
return (-1);
@@
-566,6
+580,10
@@
int rrdc_flush (const char *filename) /* {{{ */
if (status != 0)
return (ENOBUFS);
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);
status = buffer_add_string (filename, &buffer_ptr, &buffer_free);
if (status != 0)
return (ENOBUFS);
@@
-598,13
+616,23
@@
int rrdc_flush_if_daemon (const char *opt_daemon, const char *filename) /* {{{ *
if (rrdc_is_connected(opt_daemon))
{
if (rrdc_is_connected(opt_daemon))
{
+ rrd_clear_error();
status = rrdc_flush (filename);
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 (
daemon_addr
) */
+ } /* if (
rrdc_is_connected(..)
) */
return status;
} /* }}} int rrdc_flush_if_daemon */
return status;
} /* }}} int rrdc_flush_if_daemon */
@@
-733,7
+761,7
@@
void rrdc_stats_free (rrdc_stats_t *ret_stats) /* {{{ */
if (this->name != NULL)
{
if (this->name != NULL)
{
- free (this->name);
+ free (
(char *)
this->name);
this->name = NULL;
}
free (this);
this->name = NULL;
}
free (this);