aboutsummaryrefslogtreecommitdiffstats
path: root/src/controller.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-30 17:48:08 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-11-30 17:48:08 +0300
commit632e13627f8ad4ebf632a8b616c62dc6622d375e (patch)
tree91654d26d1e76d8c677b0dec7be8059c0c1f86ef /src/controller.c
parent2975827e40a8e7c6e820c42921fb8792cf637450 (diff)
downloadrspamd-632e13627f8ad4ebf632a8b616c62dc6622d375e.tar.gz
rspamd-632e13627f8ad4ebf632a8b616c62dc6622d375e.zip
Check for SIGUSR1 by libevent to avoid signals collisions.
Remove greylist_storage as it was never used and is actually replaced with basic kvstorage.
Diffstat (limited to 'src/controller.c')
-rw-r--r--src/controller.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/controller.c b/src/controller.c
index 07eeef0ff..206e17f82 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -116,9 +116,6 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
{
struct timeval tv;
switch (signo) {
- case SIGUSR1:
- reopen_log (rspamd_main->logger);
- break;
case SIGINT:
case SIGTERM:
if (!wanna_die) {
@@ -136,20 +133,34 @@ sig_handler (gint signo, siginfo_t *info, void *unused)
}
static void
-sigusr_handler (gint fd, short what, void *arg)
+sigusr2_handler (gint fd, short what, void *arg)
{
struct rspamd_worker *worker = (struct rspamd_worker *)arg;
/* Do not accept new connections, preparing to end worker's process */
struct timeval tv;
tv.tv_sec = 2;
tv.tv_usec = 0;
- event_del (&worker->sig_ev);
+ event_del (&worker->sig_ev_usr1);
+ event_del (&worker->sig_ev_usr2);
event_del (&worker->bind_ev);
msg_info ("controller's shutdown is pending in %d sec", 2);
event_loopexit (&tv);
return;
}
+/*
+ * Reopen log is designed by sending sigusr1 to active workers and pending shutdown of them
+ */
+static void
+sigusr1_handler (gint fd, short what, void *arg)
+{
+ struct rspamd_worker *worker = (struct rspamd_worker *) arg;
+
+ reopen_log (worker->srv->logger);
+
+ return;
+}
+
static void
free_session (void *ud)
{
@@ -1231,9 +1242,14 @@ start_controller (struct rspamd_worker *worker)
sigprocmask (SIG_UNBLOCK, &signals.sa_mask, NULL);
/* SIGUSR2 handler */
- signal_set (&worker->sig_ev, SIGUSR2, sigusr_handler, (void *)worker);
- event_base_set (ctx->ev_base, &worker->sig_ev);
- signal_add (&worker->sig_ev, NULL);
+ signal_set (&worker->sig_ev_usr2, SIGUSR2, sigusr2_handler, (void *) worker);
+ event_base_set (ctx->ev_base, &worker->sig_ev_usr2);
+ signal_add (&worker->sig_ev_usr2, NULL);
+
+ /* SIGUSR1 handler */
+ signal_set (&worker->sig_ev_usr1, SIGUSR1, sigusr1_handler, (void *) worker);
+ event_base_set (ctx->ev_base, &worker->sig_ev_usr1);
+ signal_add (&worker->sig_ev_usr1, NULL);
start_time = time (NULL);