diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-03 21:12:50 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-09-03 21:12:50 +0100 |
commit | 1b474dbb56f2c99bfd9cfc2c0adcdcd40ef69a5a (patch) | |
tree | f804c15f2406eaeb0049fe468502bc358713be3a | |
parent | 242788d0804c0c1a14e5af2920d26bdc50ff2661 (diff) | |
download | rspamd-1b474dbb56f2c99bfd9cfc2c0adcdcd40ef69a5a.tar.gz rspamd-1b474dbb56f2c99bfd9cfc2c0adcdcd40ef69a5a.zip |
[Minor] Another fix of reload case
-rw-r--r-- | src/rspamd.c | 20 | ||||
-rw-r--r-- | src/rspamd.h | 1 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/rspamd.c b/src/rspamd.c index 24ecfaa19..6508b4e8c 100644 --- a/src/rspamd.c +++ b/src/rspamd.c @@ -767,19 +767,32 @@ kill_old_workers (gpointer key, gpointer value, gpointer unused) rspamd_main = w->srv; - if (w->state == rspamd_worker_state_running) { + if (w->state == rspamd_worker_state_wanna_die) { w->state = rspamd_worker_state_terminating; kill (w->pid, SIGUSR2); ev_io_stop (rspamd_main->event_loop, &w->srv_ev); g_hash_table_remove_all (w->control_events_pending); msg_info_main ("send signal to worker %P", w->pid); } - else { + else if (w->state != rspamd_worker_state_running) { msg_info_main ("do not send signal to worker %P, already sent", w->pid); } } static void +mark_old_workers (gpointer key, gpointer value, gpointer unused) +{ + struct rspamd_worker *w = value; + struct rspamd_main *rspamd_main; + + rspamd_main = w->srv; + + if (w->state == rspamd_worker_state_running) { + w->state = rspamd_worker_state_wanna_die; + } +} + +static void rspamd_worker_wait (struct rspamd_worker *w) { struct rspamd_main *rspamd_main; @@ -1116,9 +1129,12 @@ rspamd_hup_handler (struct ev_loop *loop, ev_signal *w, int revents) if (reread_config (rspamd_main)) { rspamd_check_core_limits (rspamd_main); + /* Mark old workers */ + g_hash_table_foreach (rspamd_main->workers, mark_old_workers, NULL); msg_info_main ("spawn workers with a new config"); spawn_workers (rspamd_main, rspamd_main->event_loop); msg_info_main ("workers spawning has been finished"); + /* Kill marked */ msg_info_main ("kill old workers"); g_hash_table_foreach (rspamd_main->workers, kill_old_workers, NULL); } diff --git a/src/rspamd.h b/src/rspamd.h index 0755acc0d..2dfb512bc 100644 --- a/src/rspamd.h +++ b/src/rspamd.h @@ -87,6 +87,7 @@ struct rspamd_worker_heartbeat { enum rspamd_worker_state { rspamd_worker_state_running = 0, + rspamd_worker_state_wanna_die, rspamd_worker_state_terminating, rspamd_worker_wait_connections, rspamd_worker_wait_final_scripts, |