summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1b5a653)
raw | patch | inline | side by side (parent: 1b5a653)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 17 Jan 2009 10:01:10 +0000 (11:01 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 17 Jan 2009 10:01:10 +0000 (11:01 +0100) |
The `-T' option used to basically quit the daemon right away when the
first read function of a plugin failed. This patch changes the behavior,
so that:
- All read-functions are tried. If one or more fail, the daemon will
exit with a non-zero exit status, but all read-functions will be
tried.
- Don't quit if one read-function failed without calling all the
shutdown-functions first. This will clean up the UNIX socket of the
unixsock plugin and stuff like that.
first read function of a plugin failed. This patch changes the behavior,
so that:
- All read-functions are tried. If one or more fail, the daemon will
exit with a non-zero exit status, but all read-functions will be
tried.
- Don't quit if one read-function failed without calling all the
shutdown-functions first. This will clean up the UNIX socket of the
unixsock plugin and stuff like that.
src/collectd.c | patch | blob | history | |
src/plugin.c | patch | blob | history |
diff --git a/src/collectd.c b/src/collectd.c
index 57701c0cb6ee456d78aba397fdbf05f284d7fb44..548a8fdd989c0772cb8b361079cdccbda4377edd 100644 (file)
--- a/src/collectd.c
+++ b/src/collectd.c
pid_t pid;
int daemonize = 1;
#endif
+ int exit_status = 0;
/* read options */
while (1)
* run the actual loops
*/
do_init ();
+
if (test_readall)
{
- if (plugin_read_all_once ())
- return (1);
+ if (plugin_read_all_once () != 0)
+ exit_status = 1;
}
else
+ {
+ INFO ("Initialization complete, entering read-loop.");
do_loop ();
+ }
/* close syslog */
- INFO ("Exiting normally");
+ INFO ("Exiting normally.");
do_shutdown ();
pidfile_remove ();
#endif /* COLLECT_DAEMON */
- return (0);
+ return (exit_status);
} /* int main */
diff --git a/src/plugin.c b/src/plugin.c
index 510f92b103f4b25e13c177ff209b497145141137..bf707eca82d6e20d2261b46fd6055016b77f4686 100644 (file)
--- a/src/plugin.c
+++ b/src/plugin.c
pthread_mutex_unlock (&read_lock);
} /* void plugin_read_all */
+/* Read function called when the `-T' command line argument is given. */
int plugin_read_all_once (void)
{
llentry_t *le;
read_func_t *rf;
int status;
+ int return_status = 0;
if (list_read == NULL)
+ {
+ NOTICE ("No read-functions are registered.");
return (0);
+ }
for (le = llist_head (list_read);
le != NULL;
{
NOTICE ("read-function of plugin `%s' failed.",
le->key);
- return status;
+ return_status = -1;
}
}
- return (0);
-} /* void plugin_read_all_once */
+ return (return_status);
+} /* int plugin_read_all_once */
int plugin_write (const char *plugin, /* {{{ */
const data_set_t *ds, const value_list_t *vl)