]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix abstract context layout
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Jun 2017 09:27:13 +0000 (10:27 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 14 Jun 2017 09:27:13 +0000 (10:27 +0100)
src/controller.c
src/fuzzy_storage.c
src/hs_helper.c
src/log_helper.c
src/lua_worker.c
src/rspamd.h
src/rspamd_proxy.c
src/worker.c
src/worker_private.h

index f1daba22c2f95520ee42b6b5c24ff48856cd3c9b..b72f0ad4fe3a557c1aaabf14c4d982f8d7b22d4e 100644 (file)
@@ -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 */
index 99b98ceff994293bd925cca9cc1431f22a4ed10f..6ffecf093b802c4fab4999ea6f8b09eaae7666c7 100644 (file)
@@ -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];
index 208ebe4e4f1d10cb709f858fd129e3d562c72b68..0031f029dde6570ce4431eb6f093aee50680653f 100644 (file)
@@ -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
index ade8dd3a9f5c9c9a1e491298ad6874f348ad1930..84e485045b6e85c6edf70761bbe83894f62393ec 100644 (file)
@@ -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];
 };
index 484f79722be405fbc64908496ef01ea4f6816220..ffd9df531d390d13cd621466481de2b1bad78c3e 100644 (file)
@@ -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;
 };
index a9638ebe24bfc2bf118ef5ceb5a470adc2d96b7f..a716c37880227c838e02f1464e13ec026f90957b 100644 (file)
@@ -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[];
 };
 
index fdad35f2dac695648e3c96fd7f474e286022944b..f96e008b710d9f3c4adff2f8fc8aeb235f54e174 100644 (file)
@@ -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 */
index 80bf13d80b5f284838b0cc93aa9161de40f74e4a..49336e22d664baff4becb9581a09d9252dbde1cf 100644 (file)
@@ -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) {
index b9a9e57d6fc537366da0ba59393df9a029a5e9a4..d3339ea264ca8380301158194e02863c0f91cad4 100644 (file)
@@ -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;
 };
 
 /*