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/fuzzy_storage.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/fuzzy_storage.c')
-rw-r--r-- | src/fuzzy_storage.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 408d39960..d8344b96c 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -34,7 +34,6 @@ #include "cfg_file.h" #include "cfg_xml.h" #include "url.h" -#include "modules.h" #include "message.h" #include "fuzzy.h" #include "bloom.h" @@ -63,6 +62,20 @@ /* Current version of fuzzy hash file format */ #define CURRENT_FUZZY_VERSION 1 +/* Init functions */ +gpointer init_fuzzy (); +void start_fuzzy (struct rspamd_worker *worker); + +worker_t fuzzy_worker = { + "fuzzy", /* Name */ + init_fuzzy, /* Init function */ + start_fuzzy, /* Start function */ + TRUE, /* Has socket */ + TRUE, /* Non unique */ + FALSE, /* Non threaded */ + FALSE /* Non killable */ +}; + static GQueue *hashes[BUCKETS]; static GQueue *frequent; #ifdef WITH_JUDY @@ -756,9 +769,12 @@ sync_callback (gint fd, short what, void *arg) } gpointer -init_fuzzy_storage (void) +init_fuzzy (void) { struct rspamd_fuzzy_storage_ctx *ctx; + GQuark type; + + type = g_quark_try_string ("fuzzy"); ctx = g_malloc0 (sizeof (struct rspamd_fuzzy_storage_ctx)); @@ -766,15 +782,15 @@ init_fuzzy_storage (void) ctx->frequent_score = DEFAULT_FREQUENT_SCORE; ctx->expire = DEFAULT_EXPIRE; - register_worker_opt (TYPE_FUZZY, "hashfile", xml_handle_string, ctx, + register_worker_opt (type, "hashfile", xml_handle_string, ctx, G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, hashfile)); - register_worker_opt (TYPE_FUZZY, "max_mods", xml_handle_uint32, ctx, + register_worker_opt (type, "max_mods", xml_handle_uint32, ctx, G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, max_mods)); - register_worker_opt (TYPE_FUZZY, "frequent_score", xml_handle_uint32, ctx, + register_worker_opt (type, "frequent_score", xml_handle_uint32, ctx, G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, frequent_score)); - register_worker_opt (TYPE_FUZZY, "expire", xml_handle_seconds, ctx, + register_worker_opt (type, "expire", xml_handle_seconds, ctx, G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, expire)); - register_worker_opt (TYPE_FUZZY, "use_judy", xml_handle_boolean, ctx, + register_worker_opt (type, "use_judy", xml_handle_boolean, ctx, G_STRUCT_OFFSET (struct rspamd_fuzzy_storage_ctx, use_judy)); return ctx; @@ -784,14 +800,13 @@ init_fuzzy_storage (void) * Start worker process */ void -start_fuzzy_storage (struct rspamd_worker *worker) +start_fuzzy (struct rspamd_worker *worker) { struct sigaction signals; struct event sev; gint retries = 0; worker->srv->pid = getpid (); - worker->srv->type = TYPE_FUZZY; event_init (); |