[collectd] [PATCH] plugin.c: Initialize plugins before checking if read callbacks are available.
Sebastian Harl
sh at tokkee.org
Wed Jul 2 16:26:46 CEST 2008
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 <sh at tokkee.org>
---
src/plugin.c | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/plugin.c b/src/plugin.c
index 4a25aaa..bf8fb08 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -584,22 +584,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)
{
@@ -612,12 +605,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)
--
1.5.6.rc2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080702/4d655d91/attachment.pgp
More information about the collectd
mailing list