diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-01-16 20:59:37 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-01-16 20:59:37 +0400 |
commit | 9bacf0d835d66aaddcdb9e664a34364f25ed2554 (patch) | |
tree | 8aa7287724a3abce1b6b63dc7215e101d44eb87d /src/worker.c | |
parent | 9f2cb66ccbce8cd0fb659b79063bcebf1d816a1d (diff) | |
download | rspamd-9bacf0d835d66aaddcdb9e664a34364f25ed2554.tar.gz rspamd-9bacf0d835d66aaddcdb9e664a34364f25ed2554.zip |
* Introduce new system of worker's and modules initialization:
- Removed legacy limitation of worker's types;
- Using GQuarks to identify workers and modules;
- Remove modules.sh script;
- Add a common system of workers and modules;
- Write management and configuration for new architecture.
Diffstat (limited to 'src/worker.c')
-rw-r--r-- | src/worker.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/worker.c b/src/worker.c index 151045c19..48f4d1936 100644 --- a/src/worker.c +++ b/src/worker.c @@ -34,7 +34,6 @@ #include "cfg_file.h" #include "cfg_xml.h" #include "url.h" -#include "modules.h" #include "message.h" #include "map.h" #include "dns.h" @@ -48,6 +47,19 @@ /* 60 seconds for worker's IO */ #define DEFAULT_WORKER_IO_TIMEOUT 60000 +gpointer init_worker (void); +void start_worker (struct rspamd_worker *worker); + +worker_t normal_worker = { + "normal", /* Name */ + init_worker, /* Init function */ + start_worker, /* Start function */ + TRUE, /* Has socket */ + FALSE, /* Non unique */ + FALSE, /* Non threaded */ + TRUE /* Killable */ +}; + #ifndef BUILD_STATIC #define MODULE_INIT_FUNC "module_init" @@ -822,18 +834,21 @@ gpointer init_worker (void) { struct rspamd_worker_ctx *ctx; + GQuark type; + + type = g_quark_try_string ("normal"); ctx = g_malloc0 (sizeof (struct rspamd_worker_ctx)); ctx->is_mime = TRUE; ctx->timeout = DEFAULT_WORKER_IO_TIMEOUT; - register_worker_opt (TYPE_WORKER, "mime", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, is_mime)); - register_worker_opt (TYPE_WORKER, "http", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, is_http)); - register_worker_opt (TYPE_WORKER, "json", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, is_json)); - register_worker_opt (TYPE_WORKER, "allow_learn", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, allow_learn)); - register_worker_opt (TYPE_WORKER, "timeout", xml_handle_seconds, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, timeout)); - register_worker_opt (TYPE_WORKER, "max_tasks", xml_handle_uint32, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, max_tasks)); + register_worker_opt (type, "mime", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, is_mime)); + register_worker_opt (type, "http", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, is_http)); + register_worker_opt (type, "json", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, is_json)); + register_worker_opt (type, "allow_learn", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, allow_learn)); + register_worker_opt (type, "timeout", xml_handle_seconds, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, timeout)); + register_worker_opt (type, "max_tasks", xml_handle_uint32, ctx, G_STRUCT_OFFSET (struct rspamd_worker_ctx, max_tasks)); return ctx; } |