summaryrefslogtreecommitdiffstats
path: root/src/worker.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-12-14 19:05:56 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-12-14 19:05:56 +0300
commit4499fc92189905fde71139822d784ab7819b181c (patch)
tree4057f60b1af82b52649d05f79a804543c57ae6f4 /src/worker.c
parent7072f8548414cf0e88babd7556f1f893c93ba3dc (diff)
downloadrspamd-4499fc92189905fde71139822d784ab7819b181c.tar.gz
rspamd-4499fc92189905fde71139822d784ab7819b181c.zip
* Finally get rid of stupid savepoints system and migrate to async events logic completely
Fix lua redis library.
Diffstat (limited to 'src/worker.c')
-rw-r--r--src/worker.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/worker.c b/src/worker.c
index 24cb0dd69..2411906b0 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -228,8 +228,6 @@ construct_task (struct rspamd_worker *worker)
memory_pool_add_destructor (new_task->task_pool,
(pool_destruct_func) g_tree_destroy,
new_task->urls);
- new_task->s =
- new_async_session (new_task->task_pool, free_task_hard, new_task);
new_task->sock = -1;
new_task->is_mime = TRUE;
@@ -489,16 +487,6 @@ read_socket (f_str_t * in, void *arg)
task->state = WRITE_ERROR;
return write_socket (task);
}
- else if (r == 0) {
- task->state = WAIT_FILTER;
- rspamd_dispatcher_pause (task->dispatcher);
- }
- else {
- process_statfiles (task);
- lua_call_post_filters (task);
- task->state = WRITE_REPLY;
- return write_socket (task);
- }
}
break;
case WRITE_REPLY:
@@ -594,6 +582,28 @@ err_socket (GError * err, void *arg)
}
/*
+ * Called if all filters are processed
+ */
+static void
+fin_task (void *arg)
+{
+ struct worker_task *task = (struct worker_task *) arg;
+
+ /* Process all statfiles */
+ process_statfiles (task);
+ /* Call post filters */
+ lua_call_post_filters (task);
+ task->state = WRITE_REPLY;
+
+ if (task->fin_callback) {
+ task->fin_callback (task->fin_arg);
+ }
+ else {
+ rspamd_dispatcher_restore (task->dispatcher);
+ }
+}
+
+/*
* Reduce number of tasks proceeded
*/
static void
@@ -670,6 +680,10 @@ accept_socket (gint fd, short what, void *arg)
ctx->tasks ++;
memory_pool_add_destructor (new_task->task_pool, (pool_destruct_func)reduce_tasks_count, &ctx->tasks);
+ /* Set up async session */
+ new_task->s =
+ new_async_session (new_task->task_pool, fin_task, free_task_hard, new_task);
+
/* Init custom filters */
#ifndef BUILD_STATIC
if (ctx->is_custom) {