From: Vsevolod Stakhov Date: Wed, 14 Jun 2017 09:27:13 +0000 (+0100) Subject: [Fix] Fix abstract context layout X-Git-Tag: 1.6.1~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=99886642f9a7570895a41287d2d5908a325b32c4;p=rspamd.git [Fix] Fix abstract context layout --- diff --git a/src/controller.c b/src/controller.c index f1daba22c..b72f0ad4f 100644 --- a/src/controller.c +++ b/src/controller.c @@ -126,12 +126,15 @@ worker_t controller_worker = { */ struct rspamd_controller_worker_ctx { guint64 magic; - guint32 timeout; - struct timeval io_tv; - /* DNS resolver */ - struct rspamd_dns_resolver *resolver; /* Events base */ struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; + /* END OF COMMON PART */ + guint32 timeout; + struct timeval io_tv; /* Whether we use ssl for this server */ gboolean use_ssl; /* Webui password */ @@ -147,8 +150,6 @@ struct rspamd_controller_worker_ctx { time_t start_time; /* Main server */ struct rspamd_main *srv; - /* Configuration */ - struct rspamd_config *cfg; /* SSL cert */ gchar *ssl_cert; /* SSL private key */ diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 99b98ceff..6ffecf093 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -124,6 +124,13 @@ static const guint64 rspamd_fuzzy_storage_magic = 0x291a3253eb1b3ea5ULL; struct rspamd_fuzzy_storage_ctx { guint64 magic; + /* Events base */ + struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; + /* END OF COMMON PART */ struct fuzzy_global_stat stat; char *hashfile; gdouble expire; @@ -139,7 +146,6 @@ struct rspamd_fuzzy_storage_ctx { const ucl_object_t *masters_map; GHashTable *master_flags; guint keypair_cache_size; - struct event_base *ev_base; gint peer_fd; struct event peer_ev; struct event stat_ev; @@ -160,8 +166,6 @@ struct rspamd_fuzzy_storage_ctx { guint updates_failed; guint updates_maxfail; guint32 collection_id; - struct rspamd_dns_resolver *resolver; - struct rspamd_config *cfg; struct rspamd_worker *worker; struct rspamd_http_connection_router *collection_rt; guchar cookie[COOKIE_SIZE]; diff --git a/src/hs_helper.c b/src/hs_helper.c index 208ebe4e4..0031f029d 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -46,13 +46,18 @@ static const guint64 rspamd_hs_helper_magic = 0x22d310157a2288a0ULL; */ struct hs_helper_ctx { guint64 magic; + /* Events base */ + struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; + /* END OF COMMON PART */ gchar *hs_dir; gboolean loaded; gdouble max_time; gdouble recompile_time; - struct rspamd_config *cfg; struct event recompile_timer; - struct event_base *ev_base; }; static gpointer diff --git a/src/log_helper.c b/src/log_helper.c index ade8dd3a9..84e485045 100644 --- a/src/log_helper.c +++ b/src/log_helper.c @@ -48,11 +48,15 @@ static const guint64 rspamd_log_helper_magic = 0x1090bb46aaa74c9aULL; */ struct log_helper_ctx { guint64 magic; - struct rspamd_config *cfg; + /* Events base */ struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; + /* END OF COMMON PART */ struct event log_ev; struct rspamd_worker_lua_script *scripts; - struct rspamd_dns_resolver *resolver; lua_State *L; gint pair[2]; }; diff --git a/src/lua_worker.c b/src/lua_worker.c index 484f79722..ffd9df531 100644 --- a/src/lua_worker.c +++ b/src/lua_worker.c @@ -53,10 +53,13 @@ static const guint64 rspamd_lua_ctx_magic = 0x8055e2652aacf96eULL; */ struct rspamd_lua_worker_ctx { guint64 magic; - /* DNS resolver */ - struct rspamd_dns_resolver *resolver; /* Events base */ struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; + /* END OF COMMON PART */ /* Other params */ GHashTable *params; /* Lua script to load */ @@ -67,8 +70,6 @@ struct rspamd_lua_worker_ctx { gint cbref_accept; /* Callback for finishing */ gint cbref_fin; - /* Config file */ - struct rspamd_config *cfg; /* The rest options */ ucl_object_t *opts; }; diff --git a/src/rspamd.h b/src/rspamd.h index a9638ebe2..a716c3788 100644 --- a/src/rspamd.h +++ b/src/rspamd.h @@ -78,6 +78,12 @@ struct rspamd_worker { struct rspamd_abstract_worker_ctx { guint64 magic; + /* Events base */ + struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; char data[]; }; diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index fdad35f2d..f96e008b7 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -99,13 +99,15 @@ static const guint64 rspamd_rspamd_proxy_magic = 0xcdeb4fd1fc351980ULL; struct rspamd_proxy_ctx { guint64 magic; - gdouble timeout; - struct timeval io_tv; - struct rspamd_config *cfg; - /* DNS resolver */ - struct rspamd_dns_resolver *resolver; /* Events base */ struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; + /* END OF COMMON PART */ + gdouble timeout; + struct timeval io_tv; /* Encryption key for clients */ struct rspamd_cryptobox_keypair *key; /* Keys cache */ diff --git a/src/worker.c b/src/worker.c index 80bf13d80..49336e22d 100644 --- a/src/worker.c +++ b/src/worker.c @@ -96,7 +96,7 @@ rspamd_worker_call_finish_handlers (struct rspamd_worker *worker) { struct rspamd_task *task; struct rspamd_config *cfg = worker->srv->cfg; - struct rspamd_worker_ctx *ctx; + struct rspamd_abstract_worker_ctx *ctx; struct rspamd_config_post_load_script *sc; if (cfg->finish_callbacks) { diff --git a/src/worker_private.h b/src/worker_private.h index b9a9e57d6..d3339ea26 100644 --- a/src/worker_private.h +++ b/src/worker_private.h @@ -27,6 +27,13 @@ static const guint64 rspamd_worker_magic = 0xb48abc69d601dc1dULL; struct rspamd_worker_ctx { guint64 magic; + /* Events base */ + struct event_base *ev_base; + /* DNS resolver */ + struct rspamd_dns_resolver *resolver; + /* Config */ + struct rspamd_config *cfg; + guint32 timeout; struct timeval io_tv; /* Detect whether this worker is mime worker */ @@ -37,20 +44,14 @@ struct rspamd_worker_ctx { gboolean is_json; /* Allow learning throught worker */ gboolean allow_learn; - /* DNS resolver */ - struct rspamd_dns_resolver *resolver; /* Limit of tasks */ guint32 max_tasks; /* Maximum time for task processing */ gdouble task_timeout; - /* Events base */ - struct event_base *ev_base; /* Encryption key */ struct rspamd_cryptobox_keypair *key; /* Keys cache */ struct rspamd_keypair_cache *keys_cache; - /* Configuration */ - struct rspamd_config *cfg; }; /*