aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/controller.c1
-rw-r--r--src/fuzzy_storage.c1
-rw-r--r--src/http_proxy.c1
-rw-r--r--src/libserver/worker_util.c14
-rw-r--r--src/libserver/worker_util.h5
-rw-r--r--src/lua_worker.c2
-rw-r--r--src/rspamd.c7
-rw-r--r--src/smtp_proxy.c1
-rw-r--r--src/worker.c1
9 files changed, 27 insertions, 6 deletions
diff --git a/src/controller.c b/src/controller.c
index 534db37e8..17494b899 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -2548,6 +2548,7 @@ start_controller_worker (struct rspamd_worker *worker)
rspamd_stat_init (worker->srv->cfg);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
g_mime_shutdown ();
rspamd_stat_close ();
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 0baebdf24..4d4171e99 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -605,6 +605,7 @@ start_fuzzy (struct rspamd_worker *worker)
rspamd_map_watch (worker->srv->cfg, ctx->ev_base);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
rspamd_fuzzy_backend_sync (ctx->backend, ctx->expire, TRUE);
rspamd_fuzzy_backend_close (ctx->backend);
diff --git a/src/http_proxy.c b/src/http_proxy.c
index c35b771ac..85ee1c4bd 100644
--- a/src/http_proxy.c
+++ b/src/http_proxy.c
@@ -471,6 +471,7 @@ start_http_proxy (struct rspamd_worker *worker)
event_add (&ctx->rotate_ev, &rot_tv);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
g_mime_shutdown ();
rspamd_log_close (worker->srv->logger);
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 5aff8883b..0e4a29a32 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -511,3 +511,17 @@ rspamd_fork_worker (struct rspamd_main *rspamd_main,
return cur;
}
+
+void
+rspamd_worker_block_signals (void)
+{
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGTERM);
+ sigaddset (&set, SIGINT);
+ sigaddset (&set, SIGHUP);
+ sigaddset (&set, SIGUSR1);
+ sigaddset (&set, SIGUSR2);
+ sigprocmask (SIG_BLOCK, &set, NULL);
+}
diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h
index 30fbe904f..741180922 100644
--- a/src/libserver/worker_util.h
+++ b/src/libserver/worker_util.h
@@ -112,6 +112,11 @@ worker_t * rspamd_get_worker_by_type (struct rspamd_config *cfg, GQuark type);
void rspamd_worker_stop_accept (struct rspamd_worker *worker);
/**
+ * Block signals before terminations
+ */
+void rspamd_worker_block_signals (void);
+
+/**
* Fork new worker with the specified configuration
*/
struct rspamd_worker *rspamd_fork_worker (struct rspamd_main *,
diff --git a/src/lua_worker.c b/src/lua_worker.c
index 7e15c632a..1e37419a2 100644
--- a/src/lua_worker.c
+++ b/src/lua_worker.c
@@ -394,6 +394,8 @@ start_lua_worker (struct rspamd_worker *worker)
rspamd_map_watch (worker->srv->cfg, ctx->ev_base);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
+
luaL_unref (L, LUA_REGISTRYINDEX, ctx->cbref_accept);
if (ctx->cbref_fin != 0) {
/* Call finalizer function */
diff --git a/src/rspamd.c b/src/rspamd.c
index 21563bf18..2377f8892 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -1043,12 +1043,7 @@ main (gint argc, gchar **argv, gchar **env)
event_base_loop (ev_base, 0);
/* We need to block signals unless children are waited for */
- sigaddset (&signals.sa_mask, SIGTERM);
- sigaddset (&signals.sa_mask, SIGINT);
- sigaddset (&signals.sa_mask, SIGHUP);
- sigaddset (&signals.sa_mask, SIGUSR1);
- sigaddset (&signals.sa_mask, SIGUSR2);
- sigprocmask (SIG_BLOCK, &signals.sa_mask, NULL);
+ rspamd_worker_block_signals ();
if (control_fd != -1) {
event_del (&control_ev);
diff --git a/src/smtp_proxy.c b/src/smtp_proxy.c
index 40e5ce473..0ae9c70c4 100644
--- a/src/smtp_proxy.c
+++ b/src/smtp_proxy.c
@@ -1079,6 +1079,7 @@ start_smtp_proxy (struct rspamd_worker *worker)
umask (S_IWGRP | S_IWOTH | S_IROTH | S_IRGRP);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
rspamd_log_close (worker->srv->logger);
exit (EXIT_SUCCESS);
diff --git a/src/worker.c b/src/worker.c
index cde69c2a1..8256b879e 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -360,6 +360,7 @@ start_worker (struct rspamd_worker *worker)
rspamd_stat_init (worker->srv->cfg);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
g_mime_shutdown ();
rspamd_stat_close ();