X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fplugin.c;h=11a0ef6eadbada45aad092f7116c879aeef9dfdd;hb=8d2f2ffd15ac83343aae58c82577b929e2e5f4ab;hp=b150cf673ef75302d02a489991a11bcf3985f184;hpb=0b9800153cec24ed79c71beaac265e33ee3001ba;p=collectd.git diff --git a/src/plugin.c b/src/plugin.c index b150cf67..11a0ef6e 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -888,6 +888,14 @@ int plugin_unregister_read (const char *name) /* {{{ */ } le = llist_search (read_list, name); + if (le == NULL) + { + pthread_mutex_unlock (&read_lock); + WARNING ("plugin_unregister_read: No such read function: %s", + name); + return (-ENOENT); + } + llist_remove (read_list, le); rf = le->value; @@ -1205,8 +1213,14 @@ void plugin_shutdown_all (void) (*callback) (); } - destroy_all_callbacks (&list_write); + /* Write plugins which use the `user_data' pointer usually need the + * same data available to the flush callback. If this is the case, set + * the free_function to NULL when registering the flush callback and to + * the real free function when registering the write callback. This way + * the data isn't freed twice. */ destroy_all_callbacks (&list_flush); + destroy_all_callbacks (&list_write); + destroy_all_callbacks (&list_notification); destroy_all_callbacks (&list_shutdown); destroy_all_callbacks (&list_log); @@ -1430,7 +1444,12 @@ void plugin_log (int level, const char *format, ...) llentry_t *le; if (list_log == NULL) + { + va_start (ap, format); + vfprintf (stderr, format, ap); + va_end (ap); return; + } #if !COLLECT_DEBUG if (level >= LOG_DEBUG)