summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libserver/events.c2
-rw-r--r--src/libserver/symbols_cache.c7
-rw-r--r--src/libserver/task.c26
-rw-r--r--src/libserver/task.h1
4 files changed, 24 insertions, 12 deletions
diff --git a/src/libserver/events.c b/src/libserver/events.c
index 687b2e97a..bd46f1686 100644
--- a/src/libserver/events.c
+++ b/src/libserver/events.c
@@ -232,8 +232,6 @@ rspamd_session_pending (struct rspamd_async_session *session)
/* Session finished incompletely, perform restoration */
if (session->restore != NULL) {
session->restore (session->user_data);
- /* Call pending once more */
- return rspamd_session_pending (session);
}
}
else {
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index b67ca8d61..40a54ad06 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -863,9 +863,11 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
if (item->type == SYMBOL_TYPE_NORMAL || item->type == SYMBOL_TYPE_CALLBACK) {
g_assert (item->func != NULL);
+ /* Check has been started */
+ setbit (checkpoint->processed_bits, item->id * 2);
t1 = rspamd_get_ticks ();
-
pending_before = rspamd_session_events_pending (task->s);
+
if (item->symbol != NULL &&
G_UNLIKELY (check_debug_symbol (task->cfg, item->symbol))) {
rspamd_log_debug (rspamd_main->logger);
@@ -882,9 +884,6 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
diff = (t2 - t1) * 1000000;
rspamd_set_counter (item, diff);
- /* Check has been started */
- setbit (checkpoint->processed_bits, item->id * 2);
-
if (pending_before == pending_after) {
/* No new events registered */
setbit (checkpoint->processed_bits, item->id * 2 + 1);
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 901fc1963..e063f0f5b 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -322,17 +322,26 @@ gboolean
rspamd_task_process (struct rspamd_task *task, guint stages)
{
gint st;
+ gboolean ret = TRUE;
+
+ /* Avoid nested calls */
+ if (task->flags & RSPAMD_TASK_FLAG_PROCESSING) {
+ return TRUE;
+ }
+
if (RSPAMD_TASK_IS_PROCESSED (task)) {
return TRUE;
}
+ task->flags |= RSPAMD_TASK_FLAG_PROCESSING;
+
st = rspamd_task_select_processing_stage (task, stages);
switch (st) {
case RSPAMD_TASK_STAGE_READ_MESSAGE:
if (!rspamd_message_parse (task)) {
- return FALSE;
+ ret = FALSE;
}
break;
@@ -342,13 +351,13 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
case RSPAMD_TASK_STAGE_FILTERS:
if (!rspamd_process_filters (task)) {
- return FALSE;
+ ret = FALSE;
}
break;
case RSPAMD_TASK_STAGE_CLASSIFIERS:
if (!rspamd_stat_classify (task, task->cfg->lua_state, &task->err)) {
- return FALSE;
+ ret = FALSE;
}
break;
@@ -362,7 +371,7 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
case RSPAMD_TASK_STAGE_DONE:
task->processed_stages |= RSPAMD_TASK_STAGE_DONE;
- return TRUE;
+ break;
default:
/* TODO: not implemented stage */
@@ -371,7 +380,12 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
if (RSPAMD_TASK_IS_SKIPPED (task)) {
task->processed_stages |= RSPAMD_TASK_STAGE_DONE;
- return TRUE;
+ }
+
+ task->flags &= ~RSPAMD_TASK_FLAG_PROCESSING;
+
+ if (!ret || RSPAMD_TASK_IS_PROCESSED (task)) {
+ return ret;
}
if (rspamd_session_events_pending (task->s) != 0) {
@@ -390,7 +404,7 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
return rspamd_task_process (task, stages);
}
- return TRUE;
+ return ret;
}
const gchar *
diff --git a/src/libserver/task.h b/src/libserver/task.h
index f0b00862b..7506b25c1 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -87,6 +87,7 @@ enum rspamd_task_stage {
#define RSPAMD_TASK_FLAG_NO_LOG (1 << 7)
#define RSPAMD_TASK_FLAG_NO_IP (1 << 8)
#define RSPAMD_TASK_FLAG_HAS_CONTROL (1 << 9)
+#define RSPAMD_TASK_FLAG_PROCESSING (1 << 10)
#define RSPAMD_TASK_IS_SKIPPED(task) (((task)->flags & RSPAMD_TASK_FLAG_SKIP))
#define RSPAMD_TASK_IS_JSON(task) (((task)->flags & RSPAMD_TASK_FLAG_JSON))