rspamd_stat_init (worker->srv->cfg);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
g_mime_shutdown ();
rspamd_stat_close ();
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);
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);
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);
+}
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
*/
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 */
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);
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);
rspamd_stat_init (worker->srv->cfg);
event_base_loop (ctx->ev_base, 0);
+ rspamd_worker_block_signals ();
g_mime_shutdown ();
rspamd_stat_close ();