diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-21 16:27:25 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-09-21 16:27:25 +0100 |
commit | 261c54963d3e48834100180125a2a17e1759cb61 (patch) | |
tree | b669a494921c42e8f4d699027c3aadb94286e777 /src/libserver/worker_util.c | |
parent | 87232e48b7eae8a4cc0ba429d8eecbf6d99e2d3a (diff) | |
download | rspamd-261c54963d3e48834100180125a2a17e1759cb61.tar.gz rspamd-261c54963d3e48834100180125a2a17e1759cb61.zip |
[Project] Allow to kill workers that hang up
Diffstat (limited to 'src/libserver/worker_util.c')
-rw-r--r-- | src/libserver/worker_util.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c index d2e52d5a1..883e7e8a9 100644 --- a/src/libserver/worker_util.c +++ b/src/libserver/worker_util.c @@ -756,6 +756,31 @@ rspamd_main_heartbeat_cb (EV_P_ ev_timer *w, int revents) g_quark_to_string (wrk->type), wrk->pid, timebuf); + + if (rspamd_main->cfg->heartbeats_loss_max > 0 && + -(wrk->hb.nbeats) >= rspamd_main->cfg->heartbeats_loss_max) { + + + if (-(wrk->hb.nbeats) >= rspamd_main->cfg->heartbeats_loss_max + 1) { + msg_err_main ("terminate worker type %s with pid %P, " + "last beat on: %s; %L heartbeat loast", + g_quark_to_string (wrk->type), + wrk->pid, + timebuf, + -(wrk->hb.nbeats)); + kill (wrk->pid, SIGTERM); + } + else { + msg_err_main ("force kill worker type %s with pid %P, " + "last beat on: %s; %L heartbeat loast", + g_quark_to_string (wrk->type), + wrk->pid, + timebuf, + -(wrk->hb.nbeats)); + kill (wrk->pid, SIGKILL); + } + + } } } else if (wrk->hb.nbeats < 0) { |