summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: af2f301)
raw | patch | inline | side by side (parent: af2f301)
author | coreykosak <coreykosak@users.noreply.github.com> | |
Mon, 2 May 2016 13:48:09 +0000 (09:48 -0400) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Mon, 2 May 2016 13:48:09 +0000 (15:48 +0200) |
After this change, the following kinds of errors will cause collectd -T to
exit with an abnormal status:
- errors reading the config file
- errors reading types.db
- errors on plugin_init
- errors on plugin_shutdown
exit with an abnormal status:
- errors reading the config file
- errors reading types.db
- errors on plugin_init
- errors on plugin_shutdown
src/daemon/collectd.c | patch | blob | history | |
src/daemon/configfile.c | patch | blob | history | |
src/daemon/plugin.c | patch | blob | history | |
src/daemon/plugin.h | patch | blob | history |
diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c
index 2576789cf582704ef58080567f585d31cbe538d6..a72ff35f2fc21ec042e809d64967100f35f5a9fd 100644 (file)
--- a/src/daemon/collectd.c
+++ b/src/daemon/collectd.c
}
#endif
- plugin_init_all ();
-
- return (0);
+ return plugin_init_all ();
} /* int do_init () */
static int do_shutdown (void)
{
- plugin_shutdown_all ();
- return (0);
+ return plugin_shutdown_all ();
} /* int do_shutdown */
#if COLLECT_DAEMON
/*
* run the actual loops
*/
- do_init ();
+ if (do_init () != 0)
+ {
+ ERROR ("Error: one or more plugin init callbacks failed.");
+ exit_status = 1;
+ }
if (test_readall)
{
if (plugin_read_all_once () != 0)
+ {
+ ERROR ("Error: one or more plugin read callbacks failed.");
exit_status = 1;
+ }
}
else
{
/* close syslog */
INFO ("Exiting normally.");
- do_shutdown ();
+ if (do_shutdown () != 0)
+ {
+ ERROR ("Error: one or more plugin shutdown callbacks failed.");
+ exit_status = 1;
+ }
#if COLLECT_DAEMON
if (daemonize)
index 70ada80a6d04a8180c0e7904658a7b90b2d3c1fe..34c23cdfad3b24c408269ae60f834aa90e18f8f4 100644 (file)
--- a/src/daemon/configfile.c
+++ b/src/daemon/configfile.c
static int dispatch_value (oconfig_item_t *ci)
{
- int ret = -2;
+ int ret = 0;
int i;
for (i = 0; i < cf_value_map_num; i++)
{
oconfig_item_t *conf;
int i;
+ int ret = 0;
conf = cf_read_generic (filename, /* pattern = */ NULL, /* depth = */ 0);
if (conf == NULL)
for (i = 0; i < conf->children_num; i++)
{
if (conf->children[i].children == NULL)
- dispatch_value (conf->children + i);
+ {
+ if (dispatch_value (conf->children + i) != 0)
+ ret = -1;
+ }
else
- dispatch_block (conf->children + i);
+ {
+ if (dispatch_block (conf->children + i) != 0)
+ ret = -1;
+ }
}
oconfig_free (conf);
/* Read the default types.db if no `TypesDB' option was given. */
if (cf_default_typesdb)
- read_types_list (PKGDATADIR"/types.db");
+ {
+ if (read_types_list (PKGDATADIR"/types.db") != 0)
+ ret = -1;
+ }
- return (0);
+ return ret;
} /* int cf_read */
/* Assures the config option is a string, duplicates it and returns the copy in
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index fa78fa024af63ab9698411175acc45699b8b0f11..3a2e28789270d8b011b6bb2f6d0057b55d1956f8 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
return (plugin_unregister (list_notification, name));
}
-void plugin_init_all (void)
+int plugin_init_all (void)
{
char const *chain_name;
llentry_t *le;
int status;
+ int ret = 0;
/* Init the value cache */
uc_init ();
}
if ((list_init == NULL) && (read_heap == NULL))
- return;
+ return ret;
/* Calling all init callbacks before checking if read callbacks
* are available allows the init callbacks to register the read
* handling themselves. */
/* FIXME: Unload _all_ functions */
plugin_unregister_read (le->key);
+ ret = -1;
}
le = le->next;
if (num != -1)
start_read_threads ((num > 0) ? num : 5);
}
+ return ret;
} /* void plugin_init_all */
/* TODO: Rename this function. */
@@ -1972,9 +1975,10 @@ int plugin_flush (const char *plugin, cdtime_t timeout, const char *identifier)
return (0);
} /* int plugin_flush */
-void plugin_shutdown_all (void)
+int plugin_shutdown_all (void)
{
llentry_t *le;
+ int ret = 0; // Assume success.
stop_read_threads ();
* after callback returns. */
le = le->next;
- (*callback) ();
+ if ((*callback) () != 0)
+ ret = -1;
plugin_set_ctx (old_ctx);
}
plugin_free_loaded ();
plugin_free_data_sets ();
+ return (ret);
} /* void plugin_shutdown_all */
int plugin_dispatch_missing (const value_list_t *vl) /* {{{ */
diff --git a/src/daemon/plugin.h b/src/daemon/plugin.h
index a63f5cdc6e5e189e0461cf982f117e6d48b55a0f..1e4b3d1815a88fb6a7594543fa855208798eadf1 100644 (file)
--- a/src/daemon/plugin.h
+++ b/src/daemon/plugin.h
*/
int plugin_load (const char *name, uint32_t flags);
-void plugin_init_all (void);
+int plugin_init_all (void);
void plugin_read_all (void);
int plugin_read_all_once (void);
-void plugin_shutdown_all (void);
+int plugin_shutdown_all (void);
/*
* NAME