diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-19 00:27:54 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-01-19 00:27:54 +0000 |
commit | 7e4a21dc554d42d31afc611fd92aaddd7da1bb6c (patch) | |
tree | 1a423d9ca90425eed230aca69d1193a3a511bf0a /src/protocol.c | |
parent | e2f2eed337ecdb17c897fe7e04626dfffe32f2a2 (diff) | |
download | rspamd-7e4a21dc554d42d31afc611fd92aaddd7da1bb6c.tar.gz rspamd-7e4a21dc554d42d31afc611fd92aaddd7da1bb6c.zip |
Simplify states of task. Disable broken code.
Diffstat (limited to 'src/protocol.c')
-rw-r--r-- | src/protocol.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/protocol.c b/src/protocol.c index 3351a5195..23ed859ad 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -687,7 +687,7 @@ rspamd_gstring_append_double (double val, void *ud) return 0; } -static gboolean +static void write_check_reply (struct rspamd_http_message *msg, struct worker_task *task) { GString *logbuf; @@ -743,28 +743,23 @@ write_check_reply (struct rspamd_http_message *msg, struct worker_task *task) /* Increase counters */ task->worker->srv->stat->messages_scanned++; - - rspamd_http_connection_write_message (task->http_conn, msg, NULL, - "application/json", task, task->sock, &task->tv, task->ev_base); - return TRUE; } -gboolean +void rspamd_protocol_write_reply (struct worker_task *task) { struct rspamd_http_message *msg; + const gchar *ctype = "text/plain"; - rspamd_http_connection_reset (task->http_conn); msg = rspamd_http_new_message (HTTP_RESPONSE); msg->date = time (NULL); + task->state = CLOSING_CONNECTION; + debug_task ("writing reply to client"); if (task->error_code != 0) { msg->code = task->error_code; - rspamd_http_connection_write_message (task->http_conn, msg, NULL, - "text/plain", task, task->sock, &task->tv, task->ev_base); - task->state = CLOSING_CONNECTION; - return TRUE; + msg->body = g_string_new (task->last_error); } else { switch (task->cmd) { @@ -774,21 +769,21 @@ rspamd_protocol_write_reply (struct worker_task *task) case CMD_SYMBOLS: case CMD_PROCESS: case CMD_SKIP: - task->state = CLOSING_CONNECTION; - return write_check_reply (msg, task); + ctype = "application/json"; + write_check_reply (msg, task); break; case CMD_PING: - rspamd_http_connection_write_message (task->http_conn, msg, NULL, - "text/plain", task, task->sock, &task->tv, task->ev_base); - task->state = CLOSING_CONNECTION; + msg->body = g_string_new ("pong"); break; case CMD_OTHER: - task->state = CLOSING_CONNECTION; - return task->custom_cmd->func (task); + msg_err ("BROKEN"); + break; } } - return FALSE; + rspamd_http_connection_reset (task->http_conn); + rspamd_http_connection_write_message (task->http_conn, msg, NULL, + ctype, task, task->sock, &task->tv, task->ev_base); } void |