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.
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 */
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)