gsize images_cache_size; /**< size of LRU cache for DCT data from images */
gdouble task_timeout; /**< maximum message processing time */
gint default_max_shots; /**< default maximum count of symbols hits permitted (-1 for unlimited) */
+ gint32 heartbeats_loss_max; /**< number of heartbeats lost to consider worker's termination */
gdouble heartbeat_interval; /**< interval for heartbeats for workers */
enum rspamd_log_type log_type; /**< log type */
G_STRUCT_OFFSET (struct rspamd_config, heartbeat_interval),
RSPAMD_CL_FLAG_TIME_FLOAT,
"Time between workers heartbeats");
+ rspamd_rcl_add_default_handler (sub,
+ "heartbeats_loss_max",
+ rspamd_rcl_parse_struct_integer,
+ G_STRUCT_OFFSET (struct rspamd_config, heartbeat_interval),
+ RSPAMD_CL_FLAG_INT_32,
+ "Maximum count of heartbeats to be lost before trying to "
+ "terminate a worker (default: 0 - disabled)");
/* Neighbours configuration */
rspamd_rcl_add_section_doc (&sub->subsections, "neighbours", "name",
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) {