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;
/* 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);
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 */
};
/**
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) {
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;
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;
#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