commit 7ffeac6: [Rework] Distinguish protocol and task flags
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Jul 16 15:28:04 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-07-16 14:34:35 +0100
URL: https://github.com/rspamd/rspamd/commit/7ffeac6f52de59a57456adbbe075fec0c4cd4c49
[Rework] Distinguish protocol and task flags
---
src/libmime/message.c | 4 +--
src/libmime/mime_expressions.c | 19 +++++++++--
src/libserver/dkim.c | 2 +-
src/libserver/protocol.c | 49 +++++++++------------------
src/libserver/protocol_internal.h | 1 -
src/libserver/task.c | 6 ++--
src/libserver/task.h | 71 ++++++++++++++++++++-------------------
src/lua/lua_task.c | 32 +++++++++++-------
src/worker.c | 3 +-
9 files changed, 94 insertions(+), 93 deletions(-)
diff --git a/src/libmime/message.c b/src/libmime/message.c
index 6483be0d9..f99efd872 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1187,8 +1187,8 @@ rspamd_message_parse (struct rspamd_task *task)
* So we check if a task has non-http format then we check for such a line
* at the beginning to avoid errors
*/
- if (!(task->flags & RSPAMD_TASK_FLAG_JSON) || (task->flags &
- RSPAMD_TASK_FLAG_LOCAL_CLIENT)) {
+ if (task->cmd != CMD_CHECK_V2 || (task->protocol_flags &
+ RSPAMD_TASK_PROTOCOL_FLAG_LOCAL_CLIENT)) {
if (len > sizeof ("From ") - 1) {
if (memcmp (p, "From ", sizeof ("From ") - 1) == 0) {
/* Skip to CRLF */
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c
index 975a112bc..7354b3aeb 100644
--- a/src/libmime/mime_expressions.c
+++ b/src/libmime/mime_expressions.c
@@ -2223,6 +2223,18 @@ rspamd_is_empty_body (struct rspamd_task *task,
} \
} while(0)
+#define TASK_PROTOCOL_FLAG_READ(flag) do { \
+ result = !!(task->protocol_flags & (flag)); \
+} while(0)
+
+#define TASK_GET_PROTOCOL_FLAG(flag, strname, macro) do { \
+ if (!found && strcmp ((flag), strname) == 0) { \
+ TASK_PROTOCOL_FLAG_READ((macro)); \
+ found = TRUE; \
+ } \
+} while(0)
+
+
static gboolean
rspamd_has_flag_expr (struct rspamd_task *task,
GArray * args,
@@ -2250,7 +2262,8 @@ rspamd_has_flag_expr (struct rspamd_task *task,
TASK_GET_FLAG (flag_str, "no_log", RSPAMD_TASK_FLAG_NO_LOG);
TASK_GET_FLAG (flag_str, "no_stat", RSPAMD_TASK_FLAG_NO_STAT);
TASK_GET_FLAG (flag_str, "skip", RSPAMD_TASK_FLAG_SKIP);
- TASK_GET_FLAG (flag_str, "extended_urls", RSPAMD_TASK_FLAG_EXT_URLS);
+ TASK_GET_PROTOCOL_FLAG (flag_str, "extended_urls",
+ RSPAMD_TASK_PROTOCOL_FLAG_EXT_URLS);
TASK_GET_FLAG (flag_str, "learn_spam", RSPAMD_TASK_FLAG_LEARN_SPAM);
TASK_GET_FLAG (flag_str, "learn_ham", RSPAMD_TASK_FLAG_LEARN_HAM);
TASK_GET_FLAG (flag_str, "greylisted", RSPAMD_TASK_FLAG_GREYLISTED);
@@ -2258,8 +2271,8 @@ rspamd_has_flag_expr (struct rspamd_task *task,
RSPAMD_TASK_FLAG_BROKEN_HEADERS);
TASK_GET_FLAG (flag_str, "skip_process",
RSPAMD_TASK_FLAG_SKIP_PROCESS);
- TASK_GET_FLAG (flag_str, "milter",
- RSPAMD_TASK_FLAG_MILTER);
+ TASK_GET_PROTOCOL_FLAG (flag_str, "milter",
+ RSPAMD_TASK_PROTOCOL_FLAG_MILTER);
TASK_GET_FLAG (flag_str, "bad_unicode",
RSPAMD_TASK_FLAG_BAD_UNICODE);
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index 69226e595..f4e92ca7c 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -3171,7 +3171,7 @@ rspamd_dkim_sign (struct rspamd_task *task, const gchar *selector,
return NULL;
}
- if (task->flags & RSPAMD_TASK_FLAG_MILTER) {
+ if (task->protocol_flags & RSPAMD_TASK_PROTOCOL_FLAG_MILTER) {
b64_data = rspamd_encode_base64_fold (sig_buf, sig_len, 70, NULL,
RSPAMD_TASK_NEWLINES_LF);
}
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 77c256971..4a470e3f0 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -345,7 +345,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
struct rspamd_http_message *msg)
{
rspamd_ftok_t *hn_tok, *hv_tok, srch;
- gboolean fl, has_ip = FALSE;
+ gboolean has_ip = FALSE;
struct rspamd_http_header *header, *h, *htmp;
gchar *ntok;
@@ -405,22 +405,6 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
msg_debug_protocol ("read filename header, value: %s", task->msg.fpath);
}
break;
- case 'j':
- case 'J':
- IF_HEADER (JSON_HEADER) {
- msg_debug_protocol ("read json header, value: %T", hv_tok);
- fl = rspamd_config_parse_flag (hv_tok->begin, hv_tok->len);
- if (fl) {
- task->flags |= RSPAMD_TASK_FLAG_JSON;
- }
- else {
- task->flags &= ~RSPAMD_TASK_FLAG_JSON;
- }
- }
- else {
- msg_debug_protocol ("wrong header: %T", hn_tok);
- }
- break;
case 'q':
case 'Q':
IF_HEADER (QUEUE_ID_HEADER) {
@@ -536,7 +520,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
srch.len = 8;
if (rspamd_ftok_casecmp (hv_tok, &srch) == 0) {
- task->flags |= RSPAMD_TASK_FLAG_EXT_URLS;
+ task->protocol_flags |= RSPAMD_TASK_PROTOCOL_FLAG_EXT_URLS;
msg_debug_protocol ("extended urls information");
}
@@ -547,7 +531,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
if (hv_tok->len == 6 &&
rspamd_lc_cmp (hv_tok->begin, "rspamc", 6) == 0) {
- task->flags |= RSPAMD_TASK_FLAG_LOCAL_CLIENT;
+ task->protocol_flags |= RSPAMD_TASK_PROTOCOL_FLAG_LOCAL_CLIENT;
}
}
break;
@@ -568,7 +552,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
IF_HEADER (MLEN_HEADER) {
msg_debug_protocol ("read message length header, value: %T",
hv_tok);
- task->flags |= RSPAMD_TASK_FLAG_HAS_CONTROL;
+ task->protocol_flags |= RSPAMD_TASK_PROTOCOL_FLAG_HAS_CONTROL;
}
IF_HEADER (MTA_TAG_HEADER) {
gchar *mta_tag;
@@ -587,7 +571,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task,
msg_debug_protocol ("read MTA-Name header, value: %s", mta_name);
}
IF_HEADER (MILTER_HEADER) {
- task->flags |= RSPAMD_TASK_FLAG_MILTER;
+ task->protocol_flags |= RSPAMD_TASK_PROTOCOL_FLAG_MILTER;
msg_debug_protocol ("read Milter header, value: %T", hv_tok);
}
break;
@@ -734,21 +718,17 @@ rspamd_protocol_handle_request (struct rspamd_task *task,
gboolean ret = TRUE;
if (msg->method == HTTP_SYMBOLS) {
- task->cmd = CMD_CHECK_V2;
- task->flags &= ~RSPAMD_TASK_FLAG_JSON;
+ task->cmd = CMD_SYMBOLS;
}
else if (msg->method == HTTP_CHECK) {
- task->cmd = CMD_CHECK_V2;
- task->flags &= ~RSPAMD_TASK_FLAG_JSON;
+ task->cmd = CMD_SYMBOLS;
}
else {
- task->flags |= RSPAMD_TASK_FLAG_JSON;
ret = rspamd_protocol_handle_url (task, msg);
}
if (msg->flags & RSPAMD_HTTP_FLAG_SPAMC) {
- task->flags &= ~RSPAMD_TASK_FLAG_JSON;
- task->flags |= RSPAMD_TASK_FLAG_SPAMC;
+ task->protocol_flags |= RSPAMD_TASK_PROTOCOL_FLAG_SPAMC;
}
return ret;
@@ -813,7 +793,7 @@ urls_protocol_cb (gpointer key, gpointer value, gpointer ud)
guint len = 0;
gsize enclen = 0;
- if (!(task->flags & RSPAMD_TASK_FLAG_EXT_URLS)) {
+ if (!(task->protocol_flags & RSPAMD_TASK_PROTOCOL_FLAG_EXT_URLS)) {
if (url->hostlen > 0) {
if (g_hash_table_lookup (cb->seen, url)) {
return;
@@ -1330,7 +1310,9 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
GString *folded_header;
dkim_sig = (GString *) dkim_sigs->data;
- if (task->flags & RSPAMD_TASK_FLAG_MILTER || !task->message) {
+ if (task->protocol_flags & RSPAMD_TASK_PROTOCOL_FLAG_MILTER ||
+ !task->message) {
+
folded_header = rspamd_header_value_fold ("DKIM-Signature",
dkim_sig->str, 80, RSPAMD_TASK_NEWLINES_LF, NULL);
}
@@ -1357,7 +1339,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
GString *folded_header;
dkim_sig = (GString *) dkim_sigs->data;
- if (task->flags & RSPAMD_TASK_FLAG_MILTER) {
+ if (task->protocol_flags & RSPAMD_TASK_PROTOCOL_FLAG_MILTER) {
folded_header = rspamd_header_value_fold ("DKIM-Signature",
dkim_sig->str, 80, RSPAMD_TASK_NEWLINES_LF, NULL);
}
@@ -1463,7 +1445,7 @@ rspamd_protocol_http_reply (struct rspamd_http_message *msg,
}
}
- if ((task->flags & RSPAMD_TASK_FLAG_COMPRESSED) &&
+ if ((task->protocol_flags & RSPAMD_TASK_PROTOCOL_FLAG_COMPRESSED) &&
rspamd_libs_reset_compression (task->cfg->libs_ctx)) {
/* We can compress output */
ZSTD_inBuffer zin;
@@ -1794,10 +1776,11 @@ rspamd_protocol_write_reply (struct rspamd_task *task, ev_tstamp timeout)
MESSAGE_FIELD_CHECK (task, message_id));
}
- if (!RSPAMD_TASK_IS_JSON (task)) {
+ if (task->cmd == CMD_SYMBOLS) {
/* Turn compatibility on */
msg->method = HTTP_SYMBOLS;
}
+
if (RSPAMD_TASK_IS_SPAMC (task)) {
msg->flags |= RSPAMD_HTTP_FLAG_SPAMC;
}
diff --git a/src/libserver/protocol_internal.h b/src/libserver/protocol_internal.h
index 1c49a04f2..f673fc74d 100644
--- a/src/libserver/protocol_internal.h
+++ b/src/libserver/protocol_internal.h
@@ -72,7 +72,6 @@ extern "C" {
#define USER_HEADER "User"
#define URLS_HEADER "URL-Format"
#define PASS_HEADER "Pass"
-#define JSON_HEADER "Json"
#define HOSTNAME_HEADER "Hostname"
#define DELIVER_TO_HEADER "Deliver-To"
#define NO_LOG_HEADER "Log"
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 778ca4ef5..ba9843963 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -112,7 +112,7 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg,
new_task->request_headers = kh_init (rspamd_req_headers_hash);
new_task->sock = -1;
- new_task->flags |= (RSPAMD_TASK_FLAG_MIME|RSPAMD_TASK_FLAG_JSON);
+ new_task->flags |= (RSPAMD_TASK_FLAG_MIME);
new_task->result = rspamd_create_metric_result (new_task);
new_task->queue_id = "undef";
@@ -606,7 +606,7 @@ rspamd_task_load_message (struct rspamd_task *task,
rspamd_mempool_add_destructor (task->task_pool, g_free, zout.dst);
task->msg.begin = zout.dst;
task->msg.len = zout.pos;
- task->flags |= RSPAMD_TASK_FLAG_COMPRESSED;
+ task->protocol_flags |= RSPAMD_TASK_PROTOCOL_FLAG_COMPRESSED;
msg_info_task ("loaded message from zstd compressed stream; "
"compressed: %ul; uncompressed: %ul",
@@ -628,7 +628,7 @@ rspamd_task_load_message (struct rspamd_task *task,
task->flags |= RSPAMD_TASK_FLAG_EMPTY;
}
- if (task->flags & RSPAMD_TASK_FLAG_HAS_CONTROL) {
+ if (task->protocol_flags & RSPAMD_TASK_PROTOCOL_FLAG_HAS_CONTROL) {
rspamd_ftok_t *hv = rspamd_task_get_request_header (task, MLEN_HEADER);
gulong message_len = 0;
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 5a6c85a04..d6a9fc7c9 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -92,41 +92,42 @@ enum rspamd_task_stage {
RSPAMD_TASK_STAGE_DONE)
#define RSPAMD_TASK_FLAG_MIME (1u << 0u)
-#define RSPAMD_TASK_FLAG_JSON (1u << 1u)
-#define RSPAMD_TASK_FLAG_SKIP_PROCESS (1u << 2u)
-#define RSPAMD_TASK_FLAG_SKIP (1u << 3u)
-#define RSPAMD_TASK_FLAG_EXT_URLS (1u << 4u)
-#define RSPAMD_TASK_FLAG_SPAMC (1u << 5u)
-#define RSPAMD_TASK_FLAG_PASS_ALL (1u << 6u)
-#define RSPAMD_TASK_FLAG_NO_LOG (1u << 7u)
-#define RSPAMD_TASK_FLAG_NO_IP (1u << 8u)
-#define RSPAMD_TASK_FLAG_HAS_CONTROL (1u << 9u)
-#define RSPAMD_TASK_FLAG_PROCESSING (1u << 10u)
-#define RSPAMD_TASK_FLAG_GTUBE (1u << 11u)
-#define RSPAMD_TASK_FLAG_FILE (1u << 12u)
-#define RSPAMD_TASK_FLAG_NO_STAT (1u << 13u)
-#define RSPAMD_TASK_FLAG_UNLEARN (1u << 14u)
-#define RSPAMD_TASK_FLAG_ALREADY_LEARNED (1u << 15u)
-#define RSPAMD_TASK_FLAG_LEARN_SPAM (1u << 16u)
-#define RSPAMD_TASK_FLAG_LEARN_HAM (1u << 17u)
-#define RSPAMD_TASK_FLAG_LEARN_AUTO (1u << 18u)
-#define RSPAMD_TASK_FLAG_BROKEN_HEADERS (1u << 19u)
-#define RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS (1u << 20u)
-#define RSPAMD_TASK_FLAG_HAS_HAM_TOKENS (1u << 21u)
-#define RSPAMD_TASK_FLAG_EMPTY (1u << 22u)
-#define RSPAMD_TASK_FLAG_LOCAL_CLIENT (1u << 23u)
-#define RSPAMD_TASK_FLAG_COMPRESSED (1u << 24u)
-#define RSPAMD_TASK_FLAG_PROFILE (1u << 25u)
-#define RSPAMD_TASK_FLAG_GREYLISTED (1u << 26u)
-#define RSPAMD_TASK_FLAG_OWN_POOL (1u << 27u)
-#define RSPAMD_TASK_FLAG_MILTER (1u << 28u)
-#define RSPAMD_TASK_FLAG_SSL (1u << 29u)
-#define RSPAMD_TASK_FLAG_BAD_UNICODE (1u << 30u)
-#define RSPAMD_TASK_FLAG_MESSAGE_REWRITE (1u << 31u)
+#define RSPAMD_TASK_FLAG_SKIP_PROCESS (1u << 1u)
+#define RSPAMD_TASK_FLAG_SKIP (1u << 2u)
+#define RSPAMD_TASK_FLAG_PASS_ALL (1u << 3u)
+#define RSPAMD_TASK_FLAG_NO_LOG (1u << 4u)
+#define RSPAMD_TASK_FLAG_NO_IP (1u << 5u)
+#define RSPAMD_TASK_FLAG_PROCESSING (1u << 6u)
+#define RSPAMD_TASK_FLAG_GTUBE (1u << 7u)
+#define RSPAMD_TASK_FLAG_FILE (1u << 8u)
+#define RSPAMD_TASK_FLAG_NO_STAT (1u << 9u)
+#define RSPAMD_TASK_FLAG_UNLEARN (1u << 10u)
+#define RSPAMD_TASK_FLAG_ALREADY_LEARNED (1u << 11u)
+#define RSPAMD_TASK_FLAG_LEARN_SPAM (1u << 12u)
+#define RSPAMD_TASK_FLAG_LEARN_HAM (1u << 13u)
+#define RSPAMD_TASK_FLAG_LEARN_AUTO (1u << 14u)
+#define RSPAMD_TASK_FLAG_BROKEN_HEADERS (1u << 15u)
+#define RSPAMD_TASK_FLAG_HAS_SPAM_TOKENS (1u << 16u)
+#define RSPAMD_TASK_FLAG_HAS_HAM_TOKENS (1u << 17u)
+#define RSPAMD_TASK_FLAG_EMPTY (1u << 18u)
+#define RSPAMD_TASK_FLAG_PROFILE (1u << 19u)
+#define RSPAMD_TASK_FLAG_GREYLISTED (1u << 20u)
+#define RSPAMD_TASK_FLAG_OWN_POOL (1u << 21u)
+#define RSPAMD_TASK_FLAG_SSL (1u << 22u)
+#define RSPAMD_TASK_FLAG_BAD_UNICODE (1u << 23u)
+#define RSPAMD_TASK_FLAG_MESSAGE_REWRITE (1u << 24u)
+#define RSPAMD_TASK_FLAG_MAX_SHIFT (24u)
+
+#define RSPAMD_TASK_PROTOCOL_FLAG_SPAMC (1u << 0u)
+#define RSPAMD_TASK_PROTOCOL_FLAG_HAS_CONTROL (1u << 1u)
+#define RSPAMD_TASK_PROTOCOL_FLAG_LOCAL_CLIENT (1u << 2u)
+#define RSPAMD_TASK_PROTOCOL_FLAG_MILTER (1u << 3u)
+#define RSPAMD_TASK_PROTOCOL_FLAG_COMPRESSED (1u << 4u)
+#define RSPAMD_TASK_PROTOCOL_FLAG_EXT_URLS (1u << 5u)
+#define RSPAMD_TASK_PROTOCOL_FLAG_MAX_SHIFT (5u)
#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_SPAMC(task) (((task)->protocol_flags & RSPAMD_TASK_PROTOCOL_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))
@@ -160,6 +161,8 @@ struct rspamd_task {
gint sock; /**< socket descriptor */
guint32 dns_requests; /**< number of DNS requests per this task */
guint32 flags; /**< Bit flags */
+ guint32 protocol_flags;
+ guint32 processed_stages; /**< bits of stages that are processed */
gchar *helo; /**< helo header value */
gchar *queue_id; /**< queue id if specified */
rspamd_inet_addr_t *from_addr; /**< from addr for a task */
@@ -191,7 +194,6 @@ struct rspamd_task {
ev_tstamp task_timestamp;
gboolean (*fin_callback) (struct rspamd_task *task, void *arg);
-
/**< callback for filters finalizing */
void *fin_arg; /**< argument for fin callback */
@@ -202,7 +204,6 @@ struct rspamd_task {
gpointer checkpoint; /**< Opaque checkpoint data */
ucl_object_t *settings; /**< Settings applied to task */
- guint32 processed_stages; /**< bits of stages that are processed */
struct rspamd_config_settings_elt *settings_elt; /**< preprocessed settings id elt */
const gchar *classifier; /**< Classifier to learn (if needed) */
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 41ee110e3..0bc86533b 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -4718,6 +4718,17 @@ lua_task_get_size (lua_State *L)
} \
} while(0)
+#define LUA_TASK_PROTOCOL_FLAG_READ(flag) do { \
+ lua_pushboolean(L, !!(task->protocol_flags & (flag))); \
+} while(0)
+
+#define LUA_TASK_GET_PROTOCOL_FLAG(flag, strname, macro) do { \
+ if (!found && strcmp ((flag), strname) == 0) { \
+ LUA_TASK_PROTOCOL_FLAG_READ((macro)); \
+ found = TRUE; \
+ } \
+} while(0)
+
static gint
lua_task_set_flag (lua_State *L)
{
@@ -4735,7 +4746,6 @@ lua_task_set_flag (lua_State *L)
LUA_TASK_SET_FLAG (flag, "no_log", RSPAMD_TASK_FLAG_NO_LOG, set);
LUA_TASK_SET_FLAG (flag, "no_stat", RSPAMD_TASK_FLAG_NO_STAT, set);
LUA_TASK_SET_FLAG (flag, "skip", RSPAMD_TASK_FLAG_SKIP, set);
- LUA_TASK_SET_FLAG (flag, "extended_urls", RSPAMD_TASK_FLAG_EXT_URLS, set);
LUA_TASK_SET_FLAG (flag, "learn_spam", RSPAMD_TASK_FLAG_LEARN_SPAM, set);
LUA_TASK_SET_FLAG (flag, "learn_ham", RSPAMD_TASK_FLAG_LEARN_HAM, set);
LUA_TASK_SET_FLAG (flag, "broken_headers",
@@ -4768,7 +4778,6 @@ lua_task_has_flag (lua_State *L)
LUA_TASK_GET_FLAG (flag, "no_log", RSPAMD_TASK_FLAG_NO_LOG);
LUA_TASK_GET_FLAG (flag, "no_stat", RSPAMD_TASK_FLAG_NO_STAT);
LUA_TASK_GET_FLAG (flag, "skip", RSPAMD_TASK_FLAG_SKIP);
- LUA_TASK_GET_FLAG (flag, "extended_urls", RSPAMD_TASK_FLAG_EXT_URLS);
LUA_TASK_GET_FLAG (flag, "learn_spam", RSPAMD_TASK_FLAG_LEARN_SPAM);
LUA_TASK_GET_FLAG (flag, "learn_ham", RSPAMD_TASK_FLAG_LEARN_HAM);
LUA_TASK_GET_FLAG (flag, "greylisted", RSPAMD_TASK_FLAG_GREYLISTED);
@@ -4776,14 +4785,14 @@ lua_task_has_flag (lua_State *L)
RSPAMD_TASK_FLAG_BROKEN_HEADERS);
LUA_TASK_GET_FLAG (flag, "skip_process",
RSPAMD_TASK_FLAG_SKIP_PROCESS);
- LUA_TASK_GET_FLAG (flag, "milter",
- RSPAMD_TASK_FLAG_MILTER);
LUA_TASK_GET_FLAG (flag, "bad_unicode",
RSPAMD_TASK_FLAG_BAD_UNICODE);
LUA_TASK_GET_FLAG (flag, "mime",
RSPAMD_TASK_FLAG_MIME);
LUA_TASK_GET_FLAG (flag, "message_rewrite",
RSPAMD_TASK_FLAG_MESSAGE_REWRITE);
+ LUA_TASK_GET_PROTOCOL_FLAG (flag, "milter",
+ RSPAMD_TASK_PROTOCOL_FLAG_MILTER);
if (!found) {
msg_warn_task ("unknown flag requested: %s", flag);
@@ -4810,7 +4819,7 @@ lua_task_get_flags (lua_State *L)
flags = task->flags;
- for (i = 0; i < sizeof (task->flags) * NBBY; i ++) {
+ for (i = 0; i < RSPAMD_TASK_FLAG_MAX_SHIFT; i ++) {
bit = (1U << i);
if (flags & bit) {
@@ -4831,10 +4840,6 @@ lua_task_get_flags (lua_State *L)
lua_pushstring (L, "skip");
lua_rawseti (L, -2, idx++);
break;
- case RSPAMD_TASK_FLAG_EXT_URLS:
- lua_pushstring (L, "extended_urls");
- lua_rawseti (L, -2, idx++);
- break;
case RSPAMD_TASK_FLAG_BROKEN_HEADERS:
lua_pushstring (L, "broken_headers");
lua_rawseti (L, -2, idx++);
@@ -4855,10 +4860,6 @@ lua_task_get_flags (lua_State *L)
lua_pushstring (L, "skip_process");
lua_rawseti (L, -2, idx++);
break;
- case RSPAMD_TASK_FLAG_MILTER:
- lua_pushstring (L, "milter");
- lua_rawseti (L, -2, idx++);
- break;
case RSPAMD_TASK_FLAG_MESSAGE_REWRITE:
lua_pushstring (L, "message_rewrite");
lua_rawseti (L, -2, idx++);
@@ -4868,6 +4869,11 @@ lua_task_get_flags (lua_State *L)
}
}
}
+
+ if (task->protocol_flags & RSPAMD_TASK_PROTOCOL_FLAG_MILTER) {
+ lua_pushstring (L, "milter");
+ lua_rawseti (L, -2, idx++);
+ }
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/worker.c b/src/worker.c
index 446de0799..324f211a6 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -194,8 +194,7 @@ rspamd_worker_guard_handler (EV_P_ ev_io *w, int revents)
* reliable way to distinguish between shutdown(SHUT_WR) and
* close.
*/
- if (!(task->flags & RSPAMD_TASK_FLAG_JSON) &&
- task->cfg->enable_shutdown_workaround) {
+ if (task->cmd != CMD_CHECK_V2 && task->cfg->enable_shutdown_workaround) {
msg_info_task ("workaround for shutdown enabled, please update "
"your client, this support might be removed in future");
shutdown (w->fd, SHUT_RD);
More information about the Commits
mailing list