From: Sebastian Harl Date: Wed, 2 Jul 2008 14:26:46 +0000 (+0200) Subject: src/plugin.c: Initialize plugins before checking if read callbacks are available. X-Git-Tag: collectd-4.4.2~4^2~2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7699c3ec722a9414f3342d6cd31b7be440a5da6f;p=collectd.git src/plugin.c: Initialize plugins before checking if read callbacks are available. plugin_init_all() checks if any read callbacks are available before starting the read threads. A few plugins register their read callback from their init callback though. By initializing the plugins before that the read threads are still started correctly if all plugins register the read callback in the init callback. Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- diff --git a/src/plugin.c b/src/plugin.c index 8b2803df..f1333f1d 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -568,22 +568,15 @@ void plugin_init_all (void) llentry_t *le; int status; - /* Start read-threads */ - if (list_read != NULL) - { - const char *rt; - int num; - rt = global_option_get ("ReadThreads"); - num = atoi (rt); - start_threads ((num > 0) ? num : 5); - } - /* Init the value cache */ uc_init (); - if (list_init == NULL) + if ((list_init == NULL) && (list_read == NULL)) return; + /* Calling all init callbacks before checking if read callbacks + * are available allows the init callbacks to register the read + * callback. */ le = llist_head (list_init); while (le != NULL) { @@ -596,12 +589,25 @@ void plugin_init_all (void) "failed with status %i. " "Plugin will be unloaded.", le->key, status); + /* Plugins that register read callbacks from the init + * callback should take care of appropriate error + * handling themselves. */ /* FIXME: Unload _all_ functions */ plugin_unregister_read (le->key); } le = le->next; } + + /* Start read-threads */ + if (list_read != NULL) + { + const char *rt; + int num; + rt = global_option_get ("ReadThreads"); + num = atoi (rt); + start_threads ((num > 0) ? num : 5); + } } /* void plugin_init_all */ void plugin_read_all (void)