X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fplugin.c;h=e611b8cec2067c06c9f93fd053bfe24973c80d8b;hb=a8d1499f57d3ffaff4c0ef3259a9fbf21b2953c5;hp=1aad97c1d7f073931de749bb9676874de3d2b59c;hpb=f30d553f821b4c8f806bd294973561e635133e1a;p=collectd.git diff --git a/src/plugin.c b/src/plugin.c index 1aad97c1..e611b8ce 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -580,22 +580,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) { @@ -608,12 +601,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)