X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fplugin.c;h=52a5ea088cfb9537e5d5c8f2f0b7e905413cf6b4;hp=0f360c0f3eb5a0f952440483da19ec9ead4fd3fd;hb=79a87c3315bb85a71a2e69e0abaaabbfa544d6a9;hpb=67d4532f3de0fa81004c9d7128ac2983dc95165d diff --git a/src/plugin.c b/src/plugin.c index 0f360c0f..52a5ea08 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -728,26 +728,36 @@ static int plugin_insert_read (read_func_t *rf) } } - le = llentry_create (rf->rf_name, rf); + le = llist_search (read_list, rf->rf_name); if (le == NULL) { - pthread_mutex_unlock (&read_lock); - ERROR ("plugin_insert_read: llentry_create failed."); - return (-1); - } + le = llentry_create (rf->rf_name, rf); + if (le == NULL) + { + pthread_mutex_unlock (&read_lock); + ERROR ("plugin_insert_read: llentry_create failed."); + return (-1); + } + + status = c_heap_insert (read_heap, rf); + if (status != 0) + { + pthread_mutex_unlock (&read_lock); + ERROR ("plugin_insert_read: c_heap_insert failed."); + llentry_destroy (le); + return (-1); + } - status = c_heap_insert (read_heap, rf); - if (status != 0) + /* This does not fail. */ + llist_append (read_list, le); + } + else { - pthread_mutex_unlock (&read_lock); - ERROR ("plugin_insert_read: c_heap_insert failed."); - llentry_destroy (le); - return (-1); + INFO ("plugin: plugin_insert_read: " + "read function for plugin `%s' already added.", + rf->rf_name); } - /* This does not fail. */ - llist_append (read_list, le); - pthread_mutex_unlock (&read_lock); return (0); } /* int plugin_insert_read */