"hs_helper", /* Name */
init_hs_helper, /* Init function */
start_hs_helper, /* Start function */
- RSPAMD_WORKER_UNIQUE|RSPAMD_WORKER_KILLABLE|RSPAMD_WORKER_ALWAYS_START,
- RSPAMD_WORKER_SOCKET_NONE, /* No socket */
+ RSPAMD_WORKER_UNIQUE|RSPAMD_WORKER_KILLABLE|RSPAMD_WORKER_ALWAYS_START|RSPAMD_WORKER_NO_TERMINATE_DELAY,
+ RSPAMD_WORKER_SOCKET_NONE,
RSPAMD_WORKER_VER /* Version info */
};
static ev_timer shutdown_ev, shutdown_check_ev;
ev_tstamp shutdown_ts;
- shutdown_ts = MAX (SOFT_SHUTDOWN_TIME,
- sigh->worker->srv->cfg->task_timeout * 2.0);
+ if (sigh->worker->flags & RSPAMD_WORKER_NO_TERMINATE_DELAY) {
+ shutdown_ts = 0.0;
+ }
+ else {
+ shutdown_ts = MAX (SOFT_SHUTDOWN_TIME,
+ sigh->worker->srv->cfg->task_timeout * 2.0);
+ }
rspamd_worker_ignore_signal (sigh);
sigh->worker->state = rspamd_worker_state_terminating;
shutdown_ts, 0.0);
ev_timer_start (sigh->event_loop, &shutdown_ev);
- /* This timer checks if we are ready to die and is called frequently */
- shutdown_check_ev.data = sigh->worker;
- ev_timer_init (&shutdown_check_ev, rspamd_worker_shutdown_check,
- 0.5, 0.5);
- ev_timer_start (sigh->event_loop, &shutdown_check_ev);
+ if (!(sigh->worker->flags & RSPAMD_WORKER_NO_TERMINATE_DELAY)) {
+ /* This timer checks if we are ready to die and is called frequently */
+ shutdown_check_ev.data = sigh->worker;
+ ev_timer_init (&shutdown_check_ev, rspamd_worker_shutdown_check,
+ 0.5, 0.5);
+ ev_timer_start (sigh->event_loop, &shutdown_check_ev);
+ }
+
rspamd_worker_stop_accept (sigh->worker);
}
static ev_timer shutdown_ev, shutdown_check_ev;
ev_tstamp shutdown_ts;
- shutdown_ts = MAX (SOFT_SHUTDOWN_TIME,
- sigh->worker->srv->cfg->task_timeout * 2.0);
+ if (sigh->worker->flags & RSPAMD_WORKER_NO_TERMINATE_DELAY) {
+ shutdown_ts = 0.0;
+ }
+ else {
+ shutdown_ts = MAX (SOFT_SHUTDOWN_TIME,
+ sigh->worker->srv->cfg->task_timeout * 2.0);
+ }
rspamd_worker_ignore_signal (sigh);
sigh->worker->state = rspamd_worker_state_terminating;
shutdown_ts, 0.0);
ev_timer_start (sigh->event_loop, &shutdown_ev);
- /* This timer checks if we are ready to die and is called frequently */
- shutdown_check_ev.data = sigh->worker;
- ev_timer_init (&shutdown_check_ev, rspamd_worker_shutdown_check,
- 0.5, 0.5);
- ev_timer_start (sigh->event_loop, &shutdown_check_ev);
+ if (!(sigh->worker->flags & RSPAMD_WORKER_NO_TERMINATE_DELAY)) {
+ /* This timer checks if we are ready to die and is called frequently */
+ shutdown_check_ev.data = sigh->worker;
+ ev_timer_init (&shutdown_check_ev, rspamd_worker_shutdown_check,
+ 0.5, 0.5);
+ ev_timer_start (sigh->event_loop, &shutdown_check_ev);
+ }
}
else {
+ /* Flag to die has been already set */
ev_break (sigh->event_loop, EVBREAK_ALL);
}
}
RSPAMD_WORKER_ALWAYS_START = (1 << 4),
RSPAMD_WORKER_SCANNER = (1 << 5),
RSPAMD_WORKER_CONTROLLER = (1 << 6),
+ RSPAMD_WORKER_NO_TERMINATE_DELAY = (1 << 7),
};
struct rspamd_worker_accept_event {
struct rspamd_worker_accept_event *accept_events; /**< socket events */
struct rspamd_worker_conf *cf; /**< worker config data */
gpointer ctx; /**< worker's specific data */
- enum rspamd_worker_flags flags; /**< worker's flags */
+ gint flags; /**< worker's flags (enum rspamd_worker_flags) */
gint control_pipe[2]; /**< control pipe. [0] is used by main process,
[1] is used by a worker */
gint srv_pipe[2]; /**< used by workers to request something from the