summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Leblond <eric@inl.fr>2008-11-30 00:58:00 +0100
committerEric Leblond <eric@inl.fr>2008-12-09 01:19:25 +0100
commit1a43b8095f1c898e9a601ab7f777daa0c85a429a (patch)
treeb2679ae2a43e497791bb7587b8c73d21232fa4b1 /src
parent8b6aab52b27d899060866094d416d2daf4ddc3eb (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/ulogd.c26
1 files changed, 25 insertions, 1 deletions
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);
}