diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-11-08 11:41:58 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-11-08 11:41:58 +0000 |
commit | 0bde121caee1c913475d5e0cdd70af32ad95d758 (patch) | |
tree | 1d5f6e6dfe6c2e88ee4876882b86ea6ce1ba008a /src/libserver/worker_util.c | |
parent | 7901576f5efdceb97d7df60f6cd1125130d9f6d1 (diff) | |
download | rspamd-0bde121caee1c913475d5e0cdd70af32ad95d758.tar.gz rspamd-0bde121caee1c913475d5e0cdd70af32ad95d758.zip |
[Fix] Fix termination
Diffstat (limited to 'src/libserver/worker_util.c')
-rw-r--r-- | src/libserver/worker_util.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index aff418abe..1a09dfce7 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -167,10 +167,6 @@ rspamd_worker_call_finish_handlers (struct rspamd_worker *worker) static void rspamd_worker_terminate_handlers (struct rspamd_worker *w) { - struct rspamd_abstract_worker_ctx *actx; - - actx = (struct rspamd_abstract_worker_ctx *)w->ctx; - if (w->nconns == 0 && (!(w->flags & RSPAMD_WORKER_SCANNER) || w->srv->cfg->on_term_scripts == NULL)) { /* @@ -179,10 +175,7 @@ rspamd_worker_terminate_handlers (struct rspamd_worker *w) * - No term scripts are registered * - Worker is not a scanner, so it can die safely */ - ev_break (actx->event_loop, EVBREAK_ALL); w->state = rspamd_worker_wanna_die; - - return; } else { if (w->nconns > 0) { @@ -197,17 +190,17 @@ rspamd_worker_terminate_handlers (struct rspamd_worker *w) */ if (w->state != rspamd_worker_wait_final_scripts) { w->state = rspamd_worker_wait_final_scripts; - msg_info ("performing finishing actions"); if ((w->flags & RSPAMD_WORKER_SCANNER) && rspamd_worker_call_finish_handlers (w)) { + msg_info ("performing async finishing actions"); w->state = rspamd_worker_wait_final_scripts; } else { /* * We are done now */ - ev_break (actx->event_loop, EVBREAK_ALL); + msg_info ("no async finishing actions, terminating"); w->state = rspamd_worker_wanna_die; } } @@ -234,15 +227,21 @@ rspamd_worker_shutdown_check (EV_P_ ev_timer *w, int revents) struct rspamd_worker *worker = (struct rspamd_worker *)w->data; if (worker->state != rspamd_worker_wanna_die) { - ev_timer_again (EV_A_ w); rspamd_worker_terminate_handlers (worker); if (worker->state == rspamd_worker_wanna_die) { + /* We are done, kill event loop */ ev_timer_stop (EV_A_ w); + ev_break (EV_A_ EVBREAK_ALL); + } + else { + /* Try again later */ + ev_timer_again (EV_A_ w); } } else { ev_timer_stop (EV_A_ w); + ev_break (EV_A_ EVBREAK_ALL); } } @@ -339,6 +338,9 @@ rspamd_worker_term_handler (struct rspamd_worker_signal_handler *sigh, void *arg 0.5, 0.5); ev_timer_start (sigh->event_loop, &shutdown_check_ev); } + else { + ev_break (sigh->event_loop, EVBREAK_ALL); + } } /* Stop reacting on signals */ |