From: Vsevolod Stakhov Date: Sat, 1 Nov 2014 17:05:35 +0000 (+0000) Subject: Add post-signal handler. X-Git-Tag: 0.7.3~17 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0ee5ff3f3942a0396b6dba336dee736a2f14dc4c;p=rspamd.git Add post-signal handler. --- diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index 3da7af891..99829edb0 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -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; diff --git a/src/main.h b/src/main.h index 1a6bb2560..a70db8762 100644 --- a/src/main.h +++ b/src/main.h @@ -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; };