From: Florian Forster Date: Mon, 6 Nov 2006 18:34:53 +0000 (+0100) Subject: plugin_read_all: Check the `loop' variable after each iteration and return early... X-Git-Tag: collectd-3.11.0~58 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1ed0132c7c7962a5bec018faf0bb00db3a823396;p=collectd.git plugin_read_all: Check the `loop' variable after each iteration and return early if the daemon is shutting down. Lubos Stanek has reported that the daemon may stop too slow, resulting in it being killed by impatient init-scripts. With this patch `plugin_read_all' checks the `loop' variable before entering each plugin's read-function. If the loop-variable is set to non-zero it will return early, allowing the daemon to shutdown more instantly. --- diff --git a/src/collectd.c b/src/collectd.c index 98b9a162..ef2ccc75 100644 --- a/src/collectd.c +++ b/src/collectd.c @@ -193,7 +193,7 @@ static int start_client (void) curtime = time (NULL); /* Issue all plugins */ - plugin_read_all (); + plugin_read_all (&loop); if (gettimeofday (&tv_now, NULL) < 0) { diff --git a/src/plugin.c b/src/plugin.c index be28671a..697449e2 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -276,11 +276,11 @@ void plugin_init_all (void) /* * Call `read' on all plugins (if given) */ -void plugin_read_all (void) +void plugin_read_all (const int *loop) { plugin_t *p; - for (p = first_plugin; p != NULL; p = p->next) + for (p = first_plugin; (*loop == 0) && (p != NULL); p = p->next) if (p->read != NULL) (*p->read) (); } diff --git a/src/plugin.h b/src/plugin.h index e1e2e7cf..a77c87fb 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -99,7 +99,7 @@ int plugin_load (const char *type); int plugin_load_all (char *dir); void plugin_init_all (void); -void plugin_read_all (void); +void plugin_read_all (const int *loop); void plugin_register (char *type, void (*init) (void),