rspamd_rcl_add_default_handler (sub,
"heartbeats_loss_max",
rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct rspamd_config, heartbeat_interval),
+ G_STRUCT_OFFSET (struct rspamd_config, heartbeats_loss_max),
RSPAMD_CL_FLAG_INT_32,
"Maximum count of heartbeats to be lost before trying to "
"terminate a worker (default: 0 - disabled)");
-(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",
+ if (-(wrk->hb.nbeats) > rspamd_main->cfg->heartbeats_loss_max + 1) {
+ msg_err_main ("force kill worker type %s with pid %P, "
+ "last beat on: %s; %L heartbeat lost",
g_quark_to_string (wrk->type),
wrk->pid,
timebuf,
-(wrk->hb.nbeats));
- kill (wrk->pid, SIGTERM);
+ kill (wrk->pid, SIGKILL);
}
else {
- msg_err_main ("force kill worker type %s with pid %P, "
- "last beat on: %s; %L heartbeat loast",
+ msg_err_main ("terminate worker type %s with pid %P, "
+ "last beat on: %s; %L heartbeat lost",
g_quark_to_string (wrk->type),
wrk->pid,
timebuf,
-(wrk->hb.nbeats));
- kill (wrk->pid, SIGKILL);
+ kill (wrk->pid, SIGTERM);
}
}
if (WIFEXITED (res) && WEXITSTATUS (res) == 0) {
/* Normal worker termination, do not fork one more */
- msg_info_main ("%s process %P terminated normally",
- g_quark_to_string (wrk->type),
- wrk->pid);
- need_refork = FALSE;
+
+ if (wrk->hb.nbeats < 0) {
+ 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)) {
#ifdef HAVE_OPENSSL
#include <openssl/err.h>
#include <openssl/evp.h>
+#include <src/libserver/rspamd_control.h>
#endif
struct rspamd_worker *wrk)
{
gboolean need_refork;
+ static struct rspamd_control_command cmd;
/* Turn off locking for logger */
ev_child_stop (EV_A_ w);
close (wrk->srv_pipe[0]);
}
+ cmd.type = RSPAMD_CONTROL_CHILD_CHANGE;
+ cmd.cmd.child_change.what = rspamd_child_terminated;
+ cmd.cmd.child_change.pid = wrk->pid;
+ cmd.cmd.child_change.additional = w->rstatus;
+ rspamd_control_broadcast_srv_cmd (rspamd_main, &cmd, wrk->pid);
+
REF_RELEASE (wrk->cf);
if (wrk->finish_actions) {
struct rspamd_worker_heartbeat {
ev_timer heartbeat_ev; /**< used by main for checking heartbeats and by workers to send heartbeats */
- ev_tstamp last_event;
- gint64 nbeats; /* positive for beats received, negative for beats missed */
+ ev_tstamp last_event; /**< last heartbeat received timestamp */
+ gint64 nbeats; /**< positive for beats received, negative for beats missed */
};
/**