From: Vsevolod Stakhov Date: Tue, 2 Jun 2015 08:39:50 +0000 (+0100) Subject: Rework task states definition. X-Git-Tag: 1.0.0~578^2~11 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5ea511241d12d5f9dc2709fa01860e1d9ab430bb;p=rspamd.git Rework task states definition. --- diff --git a/src/libserver/task.c b/src/libserver/task.c index 4833c0835..ba4f0c1bd 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Vsevolod Stakhov +/* Copyright (c) 2014-2015, Vsevolod Stakhov * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ rspamd_task_new (struct rspamd_worker *worker) new_task = g_slice_alloc0 (sizeof (struct rspamd_task)); new_task->worker = worker; - new_task->state = READ_MESSAGE; + if (worker) { new_task->cfg = worker->srv->cfg; if (new_task->cfg->check_all_filters) { diff --git a/src/libserver/task.h b/src/libserver/task.h index 05a50ecdc..5ce24176c 100644 --- a/src/libserver/task.h +++ b/src/libserver/task.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, Vsevolod Stakhov +/* Copyright (c) 2014-2015, Vsevolod Stakhov * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,17 @@ enum rspamd_metric_action { METRIC_ACTION_MAX }; +enum rspamd_task_stage { + RSPAMD_TASK_STAGE_CONNECT = (1 << 0), + RSPAMD_TASK_STAGE_ENVELOPE = (1 << 1), + RSPAMD_TASK_STAGE_READ_MESSAGE = (1 << 2), + RSPAMD_TASK_STAGE_PRE_FILTERS = (1 << 3), + RSPAMD_TASK_STAGE_FILTERS = (1 << 4), + RSPAMD_TASK_STAGE_CLASSIFIERS = (1 << 5), + RSPAMD_TASK_STAGE_POST_FILTERS = (1 << 6), + RSPAMD_TASK_STAGE_WRITE_REPLY = (1 << 7) +}; + #define RSPAMD_TASK_FLAG_MIME (1 << 0) #define RSPAMD_TASK_FLAG_JSON (1 << 1) #define RSPAMD_TASK_FLAG_SKIP_EXTRA (1 << 2) @@ -79,15 +90,7 @@ struct custom_command { struct rspamd_task { struct rspamd_worker *worker; /**< pointer to worker object */ struct custom_command *custom_cmd; /**< custom command if any */ - enum { - READ_MESSAGE, - WAIT_PRE_FILTER, - WAIT_FILTER, - WAIT_POST_FILTER, - WRITE_REPLY, - WRITING_REPLY, - CLOSING_CONNECTION - } state; /**< current session state */ + guint processed_stages; /**< bits of stages that are processed */ enum rspamd_command cmd; /**< command */ gint sock; /**< socket descriptor */ guint flags; /**< Bit flags */