projects
/
rrdtool.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* remove intl from build process ... someone who does actually need it should fix...
[rrdtool.git]
/
src
/
rrd_client.c
diff --git
a/src/rrd_client.c
b/src/rrd_client.c
index
013b7e3
..
0b69000
100644
(file)
--- a/
src/rrd_client.c
+++ b/
src/rrd_client.c
@@
-21,11
+21,13
@@
**/
#include "rrd.h"
**/
#include "rrd.h"
-#include "rrd_client.h"
#include "rrd_tool.h"
#include "rrd_tool.h"
+#include "rrd_client.h"
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <errno.h>
#include <assert.h>
#include <pthread.h>
#include <errno.h>
#include <assert.h>
#include <pthread.h>
@@
-33,6
+35,7
@@
#include <sys/socket.h>
#include <sys/un.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netdb.h>
+#include <limits.h>
#ifndef ENODATA
#define ENODATA ENOENT
#ifndef ENODATA
#define ENODATA ENOENT
@@
-436,8
+439,8
@@
static int rrdc_connect_network (const char *addr_orig) /* {{{ */
rrd_set_error("garbage after address: %s", port);
return (-1);
}
rrd_set_error("garbage after address: %s", port);
return (-1);
}
- } /* if (*addr =
']
') */
- else
if (strchr (addr, '.') != NULL) /* Hostname or IPv4 */
+ } /* if (*addr =
= '[
') */
+ else
{
port = rindex(addr, ':');
if (port != NULL)
{
port = rindex(addr, ':');
if (port != NULL)
@@
-452,7
+455,12
@@
static int rrdc_connect_network (const char *addr_orig) /* {{{ */
port == NULL ? RRDCACHED_DEFAULT_PORT : port,
&ai_hints, &ai_res);
if (status != 0)
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)
{
for (ai_ptr = ai_res; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
{
@@
-510,6
+518,7
@@
int rrdc_connect (const char *addr) /* {{{ */
close_connection();
}
close_connection();
}
+ rrd_clear_error ();
if (strncmp ("unix:", addr, strlen ("unix:")) == 0)
status = rrdc_connect_unix (addr + strlen ("unix:"));
else if (addr[0] == '/')
if (strncmp ("unix:", addr, strlen ("unix:")) == 0)
status = rrdc_connect_unix (addr + strlen ("unix:"));
else if (addr[0] == '/')
@@
-520,10
+529,18
@@
int rrdc_connect (const char *addr) /* {{{ */
if (status == 0 && sd >= 0)
sd_path = strdup(addr);
else
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)
rrd_set_error("Unable to connect to rrdcached: %s",
(status < 0)
- ?
"Internal error"
+ ?
(err ? err : "Internal error")
: rrd_strerror (status));
: rrd_strerror (status));
+ if (err != NULL)
+ free (err);
+ }
pthread_mutex_unlock (&lock);
return (status);
pthread_mutex_unlock (&lock);
return (status);