]> source.dussan.org Git - rspamd.git/commitdiff
Add post-signal handler.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 1 Nov 2014 17:05:35 +0000 (17:05 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 1 Nov 2014 17:05:35 +0000 (17:05 +0000)
src/libserver/worker_util.c
src/main.h

index 3da7af891fa69c4d3a78310feb124687943f29e4..99829edb0f5c7db84dfaf214e79c320c9091b69c 100644 (file)
@@ -67,6 +67,10 @@ rspamd_worker_usr2_handler (gint fd, short what, void *arg)
                msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
                event_base_loopexit (sigh->base, &tv);
        }
+
+       if (sigh->post_handler) {
+               sigh->post_handler (sigh->handler_data);
+       }
 }
 
 /*
@@ -79,6 +83,10 @@ rspamd_worker_usr1_handler (gint fd, short what, void *arg)
                        (struct rspamd_worker_signal_handler *)arg;
 
        reopen_log (sigh->worker->srv->logger);
+
+       if (sigh->post_handler) {
+               sigh->post_handler (sigh->handler_data);
+       }
 }
 
 static void
@@ -98,6 +106,10 @@ rspamd_worker_term_handler (gint fd, short what, void *arg)
                ProfilerStop ();
 #endif
        }
+
+       if (sigh->post_handler) {
+               sigh->post_handler (sigh->handler_data);
+       }
 }
 
 static void
@@ -118,7 +130,7 @@ rspamd_worker_set_signal_handler (int signo, struct rspamd_worker *worker,
 {
        struct rspamd_worker_signal_handler *sigh;
 
-       sigh = g_malloc (sizeof (*sigh));
+       sigh = g_malloc0 (sizeof (*sigh));
        sigh->signo = signo;
        sigh->worker = worker;
        sigh->base = base;
index 1a6bb2560e279f4672bbf1c03b0db11d7f2f0492..a70db8762fd127e996290ab1bcfb6b8e4a786951 100644 (file)
@@ -66,6 +66,8 @@ struct rspamd_worker_signal_handler {
        struct event ev;
        struct event_base *base;
        struct rspamd_worker *worker;
+       void (*post_handler)(void *ud);
+       void *handler_data;
 };