aboutsummaryrefslogtreecommitdiffstats
path: root/src/controller.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-02 15:34:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-06-02 15:39:37 +0100
commit5b79e6254fffc507db1f537f38deaf3b7678369b (patch)
treef2482e31bfc8c7717b36fa49def83e8f5a383fb1 /src/controller.c
parent14c2ac408c9ce0284367c463f443aa1c0f1249cc (diff)
downloadrspamd-5b79e6254fffc507db1f537f38deaf3b7678369b.tar.gz
rspamd-5b79e6254fffc507db1f537f38deaf3b7678369b.zip
Restore build.
Diffstat (limited to 'src/controller.c')
-rw-r--r--src/controller.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/src/controller.c b/src/controller.c
index 73a563340..18ce87cd0 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -942,19 +942,24 @@ rspamd_controller_check_fin_task (void *ud)
struct rspamd_http_connection_entry *conn_ent;
struct rspamd_http_message *msg;
- rspamd_process_statistics (task);
- 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;
+ /* 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;
+ return TRUE;
+ }
- return TRUE;
+ /* One more iteration */
+ return FALSE;
}
static int
@@ -1005,10 +1010,15 @@ rspamd_controller_handle_learn_common (
task->sock = conn_ent->conn->fd;
- /* XXX: Handle encrypted messages */
- if (!rspamd_task_process (task, msg, msg->body->str, msg->body->len, FALSE)) {
- msg_warn ("filters cannot be processed for %s", task->message_id);
- rspamd_controller_send_error (conn_ent, 500, task->last_error);
+ 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);
+ rspamd_session_destroy (task->s);
+ return 0;
+ }
+
+ if (!rspamd_task_process (task, RSPAMD_TASK_PROCESS_LEARN)) {
+ msg_warn ("message cannot be processed for %s", task->message_id);
+ rspamd_controller_send_error (conn_ent, task->err->code, task->err->message);
rspamd_session_destroy (task->s);
return 0;
}
@@ -1094,10 +1104,15 @@ rspamd_controller_handle_scan (struct rspamd_http_connection_entry *conn_ent,
task->http_conn = rspamd_http_connection_ref (conn_ent->conn);
task->sock = conn_ent->conn->fd;
- /* XXX: handle encrypted messages */
- if (!rspamd_task_process (task, msg, msg->body->str, msg->body->len, FALSE)) {
- msg_warn ("filters cannot be processed for %s", task->message_id);
- rspamd_controller_send_error (conn_ent, 500, task->last_error);
+ 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);
+ rspamd_session_destroy (task->s);
+ return 0;
+ }
+
+ if (!rspamd_task_process (task, RSPAMD_TASK_PROCESS_ALL)) {
+ msg_warn ("message cannot be processed for %s", task->message_id);
+ rspamd_controller_send_error (conn_ent, task->err->code, task->err->message);
rspamd_session_destroy (task->s);
return 0;
}