Many plugins and files: Convert "interval_g" and "vl->interval" to cdtime_t.
[collectd.git] / src / memcached.c
index b332157..8b4a8fc 100644 (file)
 # include <netinet/in.h>
 # include <netinet/tcp.h>
 
+/* 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"
 
@@ -171,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
                        {
@@ -297,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));
@@ -318,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));
@@ -340,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));