From 1a43b8095f1c898e9a601ab7f777daa0c85a429a Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Sun, 30 Nov 2008 00:58:00 +0100 Subject: Call pluginstance stop function when exiting The stop function of plugin was not called when ulogd2 was preparing to quit. This patch adds a call to stop for all plugins in each stack and free pluginstance. --- src/ulogd.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ulogd.c b/src/ulogd.c index ead35b5..d193b26 100644 --- a/src/ulogd.c +++ b/src/ulogd.c @@ -958,18 +958,42 @@ static void deliver_signal_pluginstances(int signal) } } +static void stop_pluginstances() +{ + struct ulogd_pluginstance_stack *stack; + struct ulogd_pluginstance *pi, *npi; + + llist_for_each_entry(stack, &ulogd_pi_stacks, stack_list) { + llist_for_each_entry_safe(pi, npi, &stack->list, list) { + if (((pi->plugin->priv_size == 0) || pi->private[0]) + && *pi->plugin->stop) { + ulogd_log(ULOGD_DEBUG, "calling stop for %s\n", + pi->plugin->name); + (*pi->plugin->stop)(pi); + pi->private[0] = 0; + } + free(pi); + } + } +} + static void sigterm_handler(int signal) { - + ulogd_log(ULOGD_NOTICE, "sigterm received, exiting\n"); deliver_signal_pluginstances(signal); + stop_pluginstances(); + if (logfile != NULL && logfile != stdout) { fclose(logfile); logfile = NULL; } + if (ulogd_logfile) + free(ulogd_logfile); + exit(0); } -- cgit v1.2.3