diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-10 14:42:33 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-08-10 14:42:33 +0100 |
commit | 68d4ae45572f4a5c2c52cd162cc2a050d75a66c9 (patch) | |
tree | e1d84e514ae31495b6919d1b582b6ca276a6df46 /src/worker.c | |
parent | 6a7437c48a8d92ac5f80756643e128f223eb582e (diff) | |
download | rspamd-68d4ae45572f4a5c2c52cd162cc2a050d75a66c9.tar.gz rspamd-68d4ae45572f4a5c2c52cd162cc2a050d75a66c9.zip |
[Fix] Extend task_timeout to postfilters stage
Diffstat (limited to 'src/worker.c')
-rw-r--r-- | src/worker.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/worker.c b/src/worker.c index 3a24f6c04..59f7f6e9e 100644 --- a/src/worker.c +++ b/src/worker.c @@ -168,11 +168,47 @@ rspamd_task_timeout (EV_P_ ev_timer *w, int revents) } } + ev_timer_again (EV_A_ w); task->processed_stages |= RSPAMD_TASK_STAGE_FILTERS; rspamd_session_cleanup (task->s); rspamd_task_process (task, RSPAMD_TASK_PROCESS_ALL); rspamd_session_pending (task->s); } + else { + /* Postprocessing timeout */ + msg_info_task ("post-processing of task time out: %.1f second spent; forced processing", + ev_now (task->event_loop) - task->task_timestamp); + + if (task->cfg->soft_reject_on_timeout) { + struct rspamd_action *action, *soft_reject; + + action = rspamd_check_action_metric (task); + + if (action->action_type != METRIC_ACTION_REJECT) { + soft_reject = rspamd_config_get_action_by_type (task->cfg, + METRIC_ACTION_SOFT_REJECT); + rspamd_add_passthrough_result (task, + soft_reject, + 0, + NAN, + "timeout post-processing message", + "task timeout", + 0); + + ucl_object_replace_key (task->messages, + ucl_object_fromstring_common ("timeout post-processing message", + 0, UCL_STRING_RAW), + "smtp_message", 0, + false); + } + } + + ev_timer_stop (EV_A_ w); + task->processed_stages |= RSPAMD_TASK_STAGE_DONE; + rspamd_session_cleanup (task->s); + rspamd_task_process (task, RSPAMD_TASK_PROCESS_ALL); + rspamd_session_pending (task->s); + } } void @@ -247,7 +283,8 @@ rspamd_worker_body_handler (struct rspamd_http_connection *conn, if (ctx->task_timeout > 0.0) { task->timeout_ev.data = task; ev_timer_init (&task->timeout_ev, rspamd_task_timeout, - ctx->task_timeout, 0.0); + ctx->task_timeout, + ctx->task_timeout); ev_timer_start (task->event_loop, &task->timeout_ev); } |