diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-11-01 17:05:35 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-11-01 17:05:35 +0000 |
commit | 0ee5ff3f3942a0396b6dba336dee736a2f14dc4c (patch) | |
tree | 323f0e821a56df2a8fe79aed2128a8a241cda81c /src | |
parent | f230a889c1781037953edef0bba63e1804366850 (diff) | |
download | rspamd-0ee5ff3f3942a0396b6dba336dee736a2f14dc4c.tar.gz rspamd-0ee5ff3f3942a0396b6dba336dee736a2f14dc4c.zip |
Add post-signal handler.
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/worker_util.c | 14 | ||||
-rw-r--r-- | src/main.h | 2 |
2 files changed, 15 insertions, 1 deletions
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; }; |