collectd.conf(5): Fix some typos and mis-formulations.
[collectd.git] / src / plugin.c
index 7dd7bd9..e985dac 100644 (file)
@@ -133,7 +133,7 @@ static int plugin_load_file (char *file)
                const char *error = lt_dlerror ();
 
                ERROR ("lt_dlopen failed: %s", error);
-               DEBUG ("lt_dlopen failed: %s", error);
+               fprintf (stderr, "lt_dlopen failed: %s\n", error);
                return (1);
        }
 
@@ -356,6 +356,10 @@ int plugin_load (const char *type)
                        ret = 0;
                        break;
                }
+               else
+               {
+                       fprintf (stderr, "Unable to load plugin %s.\n", type);
+               }
        }
 
        closedir (dh);
@@ -607,13 +611,18 @@ void plugin_shutdown_all (void)
        while (le != NULL)
        {
                callback = (int (*) (void)) le->value;
-               (*callback) ();
 
+               /* Advance the pointer before calling the callback allows
+                * shutdown functions to unregister themselves. If done the
+                * other way around the memory `le' points to will be freed
+                * after callback returns. */
                le = le->next;
+
+               (*callback) ();
        }
 } /* void plugin_shutdown_all */
 
-int plugin_dispatch_values (const char *name, const value_list_t *vl)
+int plugin_dispatch_values (const char *name, value_list_t *vl)
 {
        int (*callback) (const data_set_t *, const value_list_t *);
        data_set_t *ds;
@@ -638,6 +647,23 @@ int plugin_dispatch_values (const char *name, const value_list_t *vl)
                        vl->plugin, vl->plugin_instance,
                        ds->type, vl->type_instance);
 
+#if COLLECT_DEBUG
+       assert (ds->ds_num == vl->values_len);
+#else
+       if (ds->ds_num != vl->values_len)
+       {
+               ERROR ("plugin: ds->type = %s: (ds->ds_num = %i) != "
+                               "(vl->values_len = %i)",
+                               ds->type, ds->ds_num, vl->values_len);
+               return (-1);
+       }
+#endif
+
+       escape_slashes (vl->host, sizeof (vl->host));
+       escape_slashes (vl->plugin, sizeof (vl->plugin));
+       escape_slashes (vl->plugin_instance, sizeof (vl->plugin_instance));
+       escape_slashes (vl->type_instance, sizeof (vl->type_instance));
+
        le = llist_head (list_write);
        while (le != NULL)
        {
@@ -648,7 +674,7 @@ int plugin_dispatch_values (const char *name, const value_list_t *vl)
        }
 
        return (0);
-}
+} /* int plugin_dispatch_values */
 
 void plugin_log (int level, const char *format, ...)
 {