diff options
-rw-r--r-- | src/libserver/worker_util.c | 34 | ||||
-rw-r--r-- | src/rspamd.c | 5 | ||||
-rw-r--r-- | src/rspamd.h | 1 |
3 files changed, 25 insertions, 15 deletions
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index cf20d9591..474da2644 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -1700,7 +1700,8 @@ rspamd_check_termination_clause (struct rspamd_main *rspamd_main, { gboolean need_refork = TRUE; - if (wrk->state != rspamd_worker_state_running || rspamd_main->wanna_die) { + if (wrk->state != rspamd_worker_state_running || rspamd_main->wanna_die || + (wrk->flags & RSPAMD_WORKER_OLD_CONFIG)) { /* Do not refork workers that are intended to be terminated */ need_refork = FALSE; } @@ -1708,21 +1709,30 @@ rspamd_check_termination_clause (struct rspamd_main *rspamd_main, if (WIFEXITED (res) && WEXITSTATUS (res) == 0) { /* Normal worker termination, do not fork one more */ - if (wrk->hb.nbeats < 0 && rspamd_main->cfg->heartbeats_loss_max > 0 && - -(wrk->hb.nbeats) >= rspamd_main->cfg->heartbeats_loss_max) { - msg_info_main ("%s process %P terminated normally, but lost %L " - "heartbeats, refork it", - g_quark_to_string (wrk->type), - wrk->pid, - -(wrk->hb.nbeats)); - need_refork = TRUE; - } - else { + if (wrk->flags & RSPAMD_WORKER_OLD_CONFIG) { + /* Never re-fork old workers */ msg_info_main ("%s process %P terminated normally", - g_quark_to_string (wrk->type), + g_quark_to_string(wrk->type), wrk->pid); need_refork = FALSE; } + else { + if (wrk->hb.nbeats < 0 && rspamd_main->cfg->heartbeats_loss_max > 0 && + -(wrk->hb.nbeats) >= rspamd_main->cfg->heartbeats_loss_max) { + msg_info_main ("%s process %P terminated normally, but lost %L " + "heartbeats, refork it", + g_quark_to_string(wrk->type), + wrk->pid, + -(wrk->hb.nbeats)); + need_refork = TRUE; + } + else { + msg_info_main ("%s process %P terminated normally", + g_quark_to_string(wrk->type), + wrk->pid); + need_refork = FALSE; + } + } } else { if (WIFSIGNALED (res)) { diff --git a/src/rspamd.c b/src/rspamd.c index cea6a11a8..978980706 100644 --- a/src/rspamd.c +++ b/src/rspamd.c @@ -781,13 +781,12 @@ static void mark_old_workers (gpointer key, gpointer value, gpointer unused) { struct rspamd_worker *w = value; - struct rspamd_main __attribute__ ((unused)) *rspamd_main; - - rspamd_main = w->srv; if (w->state == rspamd_worker_state_running) { w->state = rspamd_worker_state_wanna_die; } + + w->flags |= RSPAMD_WORKER_OLD_CONFIG; } static void diff --git a/src/rspamd.h b/src/rspamd.h index eb5ce541e..7924bf0ee 100644 --- a/src/rspamd.h +++ b/src/rspamd.h @@ -67,6 +67,7 @@ enum rspamd_worker_flags { RSPAMD_WORKER_SCANNER = (1 << 5), RSPAMD_WORKER_CONTROLLER = (1 << 6), RSPAMD_WORKER_NO_TERMINATE_DELAY = (1 << 7), + RSPAMD_WORKER_OLD_CONFIG = (1 << 8), }; struct rspamd_worker_accept_event { |