From: oetiker Date: Mon, 29 Sep 2008 19:56:10 +0000 (+0000) Subject: This patch provides better error messages to the client when something X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=afb590e6dbc73ed9e1eb7015071cead52e3692d3;p=rrdtool.git This patch provides better error messages to the client when something goes wrong with the daemon. When possible, the daemon error message is passed through to rrd_set_error() on the client. Prior to this patch, most error conditions would result in "Internal error", which is not very helpful. -- kevin brintnall git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk/program@1546 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_client.c b/src/rrd_client.c index 7fa9817..44d4d60 100644 --- 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) + rrd_set_error("rrdcached: %s", ret->message); *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); + rrd_set_error("request: socket error (%d) while talking to rrdcached", + status); 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) + { + if (status < 0) + rrd_set_error("request: internal error while talking to rrdcached"); return (status); + } *ret_response = res; return (0); @@ -604,7 +612,7 @@ int rrdc_flush_if_daemon (const char *opt_daemon, const char *filename) /* {{{ * 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 */ diff --git a/src/rrd_update.c b/src/rrd_update.c index 9d3e854..5e26055 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -450,13 +450,9 @@ int rrd_update( rc = rrdc_update (argv[optind], /* file */ argc - optind - 1, /* values_num */ (void *) (argv + optind + 1)); /* values */ - if (rc != 0) - { + if (rc > 0) rrd_set_error("Failed sending the values to rrdcached: %s", - (rc < 0) - ? "Internal error" - : rrd_strerror (rc)); - } + rrd_strerror (rc)); } out: