summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4753eef)
raw | patch | inline | side by side (parent: 4753eef)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 4 Oct 2009 11:36:20 +0000 (11:36 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Sun, 4 Oct 2009 11:36:20 +0000 (11:36 +0000) |
* Report getaddrinfo() errors using gai_strerror().
* Replaced "Internal error" with a more verbose error message, if available.
-- Sebastian Harl
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1929 a5681a0c-68f1-0310-ab6d-d61299d08faa
* Replaced "Internal error" with a more verbose error message, if available.
-- Sebastian Harl
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1929 a5681a0c-68f1-0310-ab6d-d61299d08faa
program/src/rrd_client.c | patch | blob | history |
index 013b7e35e96e54c7ffa93c775b5d3091ec913e99..287f642db4754253eba0134679bf1e650f60ad45 100644 (file)
--- a/program/src/rrd_client.c
+++ b/program/src/rrd_client.c
port == NULL ? RRDCACHED_DEFAULT_PORT : port,
&ai_hints, &ai_res);
if (status != 0)
- return (status);
+ {
+ rrd_set_error ("failed to resolve address `%s' (port %s): %s",
+ addr, port == NULL ? RRDCACHED_DEFAULT_PORT : port,
+ gai_strerror (status));
+ return (-1);
+ }
for (ai_ptr = ai_res; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
{
close_connection();
}
+ rrd_clear_error ();
if (strncmp ("unix:", addr, strlen ("unix:")) == 0)
status = rrdc_connect_unix (addr + strlen ("unix:"));
else if (addr[0] == '/')
if (status == 0 && sd >= 0)
sd_path = strdup(addr);
else
+ {
+ char *err = rrd_test_error () ? rrd_get_error () : "Internal error";
+ /* err points the string that gets written to by rrd_set_error(), thus we
+ * cannot pass it to that function */
+ err = strdup (err);
rrd_set_error("Unable to connect to rrdcached: %s",
(status < 0)
- ? "Internal error"
+ ? (err ? err : "Internal error")
: rrd_strerror (status));
+ if (err != NULL)
+ free (err);
+ }
pthread_mutex_unlock (&lock);
return (status);