dns plugin: Only submit dns-traffic if either counter is non-zero.
[collectd.git] / src / unixsock.c
index 1ddd03c..a74e64e 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <sys/poll.h>
 
 #include <grp.h>
 
@@ -150,10 +149,20 @@ static int cache_insert (const data_set_t *ds, const value_list_t *vl)
        value_cache_t *vc;
        int i;
 
-       DEBUG ("unixsock plugin: cache_insert: ds->ds_num = %i;"
+       DEBUG ("unixsock plugin: cache_insert: ds->type = %s; ds->ds_num = %i;"
                        " vl->values_len = %i;",
-                       ds->ds_num, vl->values_len);
+                       ds->type, ds->ds_num, vl->values_len);
+#if COLLECT_DEBUG
        assert (ds->ds_num == vl->values_len);
+#else
+       if (ds->ds_num != vl->values_len)
+       {
+               ERROR ("unixsock plugin: ds->type = %s: (ds->ds_num = %i) != "
+                               "(vl->values_len = %i)",
+                               ds->type, ds->ds_num, vl->values_len);
+               return (-1);
+       }
+#endif
 
        vc = (value_cache_t *) malloc (sizeof (value_cache_t));
        if (vc == NULL)
@@ -784,6 +793,15 @@ static void *us_server_thread (void *arg)
        close (sock_fd);
        sock_fd = -1;
 
+       status = unlink ((sock_file != NULL) ? sock_file : US_DEFAULT_PATH);
+       if (status != 0)
+       {
+               char errbuf[1024];
+               NOTICE ("unixsock plugin: unlink (%s) failed: %s",
+                               (sock_file != NULL) ? sock_file : US_DEFAULT_PATH,
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+       }
+
        return ((void *) 0);
 } /* void *us_server_thread */
 
@@ -857,7 +875,7 @@ static int us_write (const data_set_t *ds, const value_list_t *vl)
        return (0);
 }
 
-void module_register (modreg_e load)
+void module_register (void)
 {
        plugin_register_config ("unixsock", us_config,
                        config_keys, config_keys_num);