Browse Source

Rework task states definition.

tags/1.0.0
Vsevolod Stakhov 9 years ago
parent
commit
5ea511241d
2 changed files with 15 additions and 12 deletions
  1. 2
    2
      src/libserver/task.c
  2. 13
    10
      src/libserver/task.h

+ 2
- 2
src/libserver/task.c View File

@@ -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) {

+ 13
- 10
src/libserver/task.h View File

@@ -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 */

Loading…
Cancel
Save