aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-15 09:09:07 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-09-15 09:09:07 +0100
commit4f9f87b57fd3d6d435af688d0097e7b3f5ab0301 (patch)
treefa59a88d67196e6b32eac9b393b4dfd1f4501de6 /src
parent86169d23d4477dc5b4ffe9dcc18c730881bc8a4e (diff)
downloadrspamd-4f9f87b57fd3d6d435af688d0097e7b3f5ab0301.tar.gz
rspamd-4f9f87b57fd3d6d435af688d0097e7b3f5ab0301.zip
Fix scanning via controller.
Diffstat (limited to 'src')
-rw-r--r--src/controller.c49
-rw-r--r--src/libserver/task.c2
2 files changed, 36 insertions, 15 deletions
diff --git a/src/controller.c b/src/controller.c
index 3907b2755..5704a61a1 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1002,26 +1002,43 @@ rspamd_controller_learn_fin_task (void *ud)
return TRUE;
}
+static void
+rspamd_controller_scan_reply (struct rspamd_task *task)
+{
+ struct rspamd_http_message *msg;
+ struct rspamd_http_connection_entry *conn_ent = task->fin_arg;
+
+ conn_ent = task->fin_arg;
+ msg = rspamd_http_new_message (HTTP_RESPONSE);
+ msg->date = time (NULL);
+ msg->code = 200;
+ rspamd_protocol_http_reply (msg, task);
+ rspamd_http_connection_reset (conn_ent->conn);
+ rspamd_http_connection_write_message (conn_ent->conn, msg, NULL,
+ "application/json", conn_ent, conn_ent->conn->fd, conn_ent->rt->ptv,
+ conn_ent->rt->ev_base);
+ conn_ent->is_reply = TRUE;
+}
+
static gboolean
rspamd_controller_check_fin_task (void *ud)
{
struct rspamd_task *task = ud;
- struct rspamd_http_connection_entry *conn_ent;
- struct rspamd_http_message *msg;
- /* Task is already finished or skipped */
- if (RSPAMD_TASK_IS_PROCESSED (task) || !rspamd_task_process (task,
- RSPAMD_TASK_PROCESS_ALL)) {
- conn_ent = task->fin_arg;
- msg = rspamd_http_new_message (HTTP_RESPONSE);
- msg->date = time (NULL);
- msg->code = 200;
- rspamd_protocol_http_reply (msg, task);
- rspamd_http_connection_reset (conn_ent->conn);
- rspamd_http_connection_write_message (conn_ent->conn, msg, NULL,
- "application/json", conn_ent, conn_ent->conn->fd, conn_ent->rt->ptv,
- conn_ent->rt->ev_base);
- conn_ent->is_reply = TRUE;
+ msg_debug_task ("finish task");
+
+ if (RSPAMD_TASK_IS_PROCESSED (task)) {
+ rspamd_controller_scan_reply (task);
+ return TRUE;
+ }
+
+ if (!rspamd_task_process (task, RSPAMD_TASK_PROCESS_ALL)) {
+ rspamd_controller_scan_reply (task);
+ return TRUE;
+ }
+
+ if (RSPAMD_TASK_IS_PROCESSED (task)) {
+ rspamd_controller_scan_reply (task);
return TRUE;
}
@@ -1170,6 +1187,8 @@ rspamd_controller_handle_scan (struct rspamd_http_connection_entry *conn_ent,
task->fin_arg = conn_ent;
task->http_conn = rspamd_http_connection_ref (conn_ent->conn);
task->sock = conn_ent->conn->fd;
+ task->flags |= RSPAMD_TASK_FLAG_MIME;
+ task->resolver = ctx->resolver;
if (!rspamd_task_load_message (task, msg, msg->body->str, msg->body->len)) {
rspamd_controller_send_error (conn_ent, task->err->code, task->err->message);
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 8c9f8b282..ce765b8f0 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -477,6 +477,8 @@ rspamd_task_process (struct rspamd_task *task, guint stages)
task->processed_stages |= RSPAMD_TASK_STAGE_DONE;
}
+ msg_debug_task ("task is processed", st);
+
return ret;
}