X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmemcached.c;h=8b4a8fc1b9a2495fb966442ff96ffad386787f5a;hb=a04ffbda508739433df0975328100e33e7986c87;hp=3421f824f0cfed67b1173dccc263c4f7021ccd72;hpb=cad58fa441765c7a3e8868a0938a3b221bb307cc;p=collectd.git diff --git a/src/memcached.c b/src/memcached.c index 3421f824..8b4a8fc1 100644 --- a/src/memcached.c +++ b/src/memcached.c @@ -38,6 +38,11 @@ # include # include +/* Hack to work around the missing define in AIX */ +#ifndef MSG_DONTWAIT +# define MSG_DONTWAIT MSG_NONBLOCK +#endif + #define MEMCACHED_DEF_HOST "127.0.0.1" #define MEMCACHED_DEF_PORT "11211" @@ -67,7 +72,8 @@ static int memcached_query_daemon (char *buffer, int buffer_size) /* {{{ */ memset (&serv_addr, 0, sizeof (serv_addr)); serv_addr.sun_family = AF_UNIX; - sstrncpy (serv_addr.sun_path, memcached_socket, sizeof (serv_addr.sun_path)); + sstrncpy (serv_addr.sun_path, memcached_socket, + sizeof (serv_addr.sun_path)); /* create our socket descriptor */ fd = socket (AF_UNIX, SOCK_STREAM, 0); @@ -80,7 +86,7 @@ static int memcached_query_daemon (char *buffer, int buffer_size) /* {{{ */ /* connect to the memcached daemon */ status = (ssize_t) connect (fd, (struct sockaddr *) &serv_addr, - SUN_LEN (&serv_addr)); + sizeof (serv_addr)); if (status != 0) { shutdown (fd, SHUT_RDWR); close (fd); @@ -114,7 +120,7 @@ static int memcached_query_daemon (char *buffer, int buffer_size) /* {{{ */ port = MEMCACHED_DEF_PORT; } - if ((ai_return = getaddrinfo (host, port, NULL, &ai_list)) != 0) { + if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0) { char errbuf[1024]; ERROR ("memcached: getaddrinfo (%s, %s): %s", host, port, @@ -170,12 +176,14 @@ static int memcached_query_daemon (char *buffer, int buffer_size) /* {{{ */ p.events = POLLIN | POLLERR | POLLHUP; p.revents = 0; - status = poll (&p, /* nfds = */ 1, /* timeout = */ 1000 * interval_g); + status = poll (&p, /* nfds = */ 1, + /* timeout = */ CDTIME_T_TO_MS (interval_g)); if (status <= 0) { if (status == 0) { - ERROR ("memcached: poll(2) timed out after %i seconds.", interval_g); + ERROR ("memcached: poll(2) timed out after %.3f seconds.", + CDTIME_T_TO_DOUBLE (interval_g)); } else { @@ -296,7 +304,6 @@ static void submit_counter2 (const char *type, const char *type_inst, vl.values = values; vl.values_len = 2; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin)); sstrncpy (vl.type, type, sizeof (vl.type)); @@ -317,7 +324,6 @@ static void submit_gauge (const char *type, const char *type_inst, vl.values = values; vl.values_len = 1; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin)); sstrncpy (vl.type, type, sizeof (vl.type)); @@ -339,7 +345,6 @@ static void submit_gauge2 (const char *type, const char *type_inst, vl.values = values; vl.values_len = 2; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "memcached", sizeof (vl.plugin)); sstrncpy (vl.type, type, sizeof (vl.type));