aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libmime/message.c6
-rw-r--r--src/libserver/symbols_cache.c5
-rw-r--r--src/libserver/symbols_cache.h3
-rw-r--r--src/libserver/task.c19
-rw-r--r--src/libserver/task.h2
5 files changed, 23 insertions, 12 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 6b6af40e3..1f218e8b7 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1569,6 +1569,12 @@ rspamd_message_parse (struct rspamd_task *task)
gint diff, *pdiff, i;
guint tw, dw;
+ if (RSPAMD_TASK_IS_EMPTY (task)) {
+ /* Don't do anything with empty task */
+
+ return TRUE;
+ }
+
tmp = rspamd_mempool_alloc (task->task_pool, sizeof (GByteArray));
p = task->msg.begin;
len = task->msg.len;
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 8b530cefe..717018e25 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -1086,7 +1086,10 @@ rspamd_symbols_cache_check_symbol (struct rspamd_task *task,
/* Check has been started */
setbit (checkpoint->processed_bits, item->id * 2);
- if (item->condition_cb != -1) {
+ if (RSPAMD_TASK_IS_EMPTY (task) && !(item->type & SYMBOL_TYPE_EMPTY)) {
+ check = FALSE;
+ }
+ else if (item->condition_cb != -1) {
/* We also executes condition callback to check if we need this symbol */
L = task->cfg->lua_state;
lua_rawgeti (L, LUA_REGISTRYINDEX, item->condition_cb);
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index 692d6c060..56008d2c1 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -35,7 +35,8 @@ enum rspamd_symbol_type {
SYMBOL_TYPE_SKIPPED = (1 << 4),
SYMBOL_TYPE_COMPOSITE = (1 << 5),
SYMBOL_TYPE_CLASSIFIER = (1 << 6),
- SYMBOL_TYPE_FINE = (1 << 7)
+ SYMBOL_TYPE_FINE = (1 << 7),
+ SYMBOL_TYPE_EMPTY = (1 << 8) /* Allow execution on empty tasks */
};
/**
diff --git a/src/libserver/task.c b/src/libserver/task.c
index bf337cbaa..492a69d72 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -326,11 +326,7 @@ rspamd_task_load_message (struct rspamd_task *task,
task->msg.len = len;
if (task->msg.len == 0) {
- msg_warn_task ("message has invalid message length: %uz",
- task->msg.len);
- g_set_error (&task->err, rspamd_task_quark(), RSPAMD_PROTOCOL_ERROR,
- "Invalid length");
- return FALSE;
+ task->flags |= RSPAMD_TASK_FLAG_EMPTY;
}
if (task->flags & RSPAMD_TASK_FLAG_HAS_CONTROL) {
@@ -447,10 +443,12 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
case RSPAMD_TASK_STAGE_CLASSIFIERS:
case RSPAMD_TASK_STAGE_CLASSIFIERS_PRE:
case RSPAMD_TASK_STAGE_CLASSIFIERS_POST:
- if (rspamd_stat_classify (task, task->cfg->lua_state, st, &stat_error) ==
- RSPAMD_STAT_PROCESS_ERROR) {
- msg_err_task ("classify error: %e", stat_error);
- g_error_free (stat_error);
+ if (!RSPAMD_TASK_IS_EMPTY (task)) {
+ if (rspamd_stat_classify (task, task->cfg->lua_state, st, &stat_error) ==
+ RSPAMD_STAT_PROCESS_ERROR) {
+ msg_err_task ("classify error: %e", stat_error);
+ g_error_free (stat_error);
+ }
}
break;
@@ -460,7 +458,8 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
case RSPAMD_TASK_STAGE_POST_FILTERS:
rspamd_lua_call_post_filters (task);
- if (task->flags & RSPAMD_TASK_FLAG_LEARN_AUTO) {
+ if ((task->flags & RSPAMD_TASK_FLAG_LEARN_AUTO) &&
+ !RSPAMD_TASK_IS_EMPTY (task)) {
rspamd_stat_check_autolearn (task);
}
break;
diff --git a/src/libserver/task.h b/src/libserver/task.h
index c27d4bcb5..40ece993f 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -102,12 +102,14 @@ enum rspamd_task_stage {
#define RSPAMD_TASK_FLAG_BROKEN_HEADERS (1 << 19)
#define RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS (1 << 20)
#define RSPAMD_TASK_FLAG_HAS_HAM_TOKENS (1 << 21)
+#define RSPAMD_TASK_FLAG_EMPTY (1 << 22)
#define RSPAMD_TASK_IS_SKIPPED(task) (((task)->flags & RSPAMD_TASK_FLAG_SKIP))
#define RSPAMD_TASK_IS_JSON(task) (((task)->flags & RSPAMD_TASK_FLAG_JSON))
#define RSPAMD_TASK_IS_SPAMC(task) (((task)->flags & RSPAMD_TASK_FLAG_SPAMC))
#define RSPAMD_TASK_IS_PROCESSED(task) (((task)->processed_stages & RSPAMD_TASK_STAGE_DONE))
#define RSPAMD_TASK_IS_CLASSIFIED(task) (((task)->processed_stages & RSPAMD_TASK_STAGE_CLASSIFIERS))
+#define RSPAMD_TASK_IS_EMPTY(task) (((task)->flags & RSPAMD_TASK_FLAG_EMPTY))
/**
* Worker task structure