diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controller.c | 4 | ||||
-rw-r--r-- | src/fuzzy_storage.c | 4 | ||||
-rw-r--r-- | src/hs_helper.c | 3 | ||||
-rw-r--r-- | src/http_proxy.c | 4 | ||||
-rw-r--r-- | src/libserver/protocol.c | 1 | ||||
-rw-r--r-- | src/lua_worker.c | 3 | ||||
-rw-r--r-- | src/rspamd.h | 5 | ||||
-rw-r--r-- | src/smtp_proxy.c | 4 | ||||
-rw-r--r-- | src/worker.c | 40 |
9 files changed, 30 insertions, 38 deletions
diff --git a/src/controller.c b/src/controller.c index 6aefe0719..f3e21730e 100644 --- a/src/controller.c +++ b/src/controller.c @@ -99,6 +99,8 @@ const struct timeval rrd_update_time = { .tv_usec = 0 }; +const guint64 rspamd_controller_ctx_magic = 0xf72697805e6941faULL; + gpointer init_controller_worker (struct rspamd_config *cfg); void start_controller_worker (struct rspamd_worker *worker); @@ -114,6 +116,7 @@ worker_t controller_worker = { * Worker's context */ struct rspamd_controller_worker_ctx { + guint64 magic; guint32 timeout; struct timeval io_tv; /* DNS resolver */ @@ -2397,6 +2400,7 @@ init_controller_worker (struct rspamd_config *cfg) ctx = g_malloc0 (sizeof (struct rspamd_controller_worker_ctx)); + ctx->magic = rspamd_controller_ctx_magic; ctx->timeout = DEFAULT_WORKER_IO_TIMEOUT; rspamd_rcl_register_worker_option (cfg, diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index b37d6766c..4ab92cc9f 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -84,7 +84,10 @@ struct fuzzy_key_stat { rspamd_lru_hash_t *last_ips; }; +static const guint64 rspamd_fuzzy_storage_magic = 0x291a3253eb1b3ea5ULL; + struct rspamd_fuzzy_storage_ctx { + guint64 magic; struct fuzzy_global_stat stat; char *hashfile; gdouble expire; @@ -1204,6 +1207,7 @@ init_fuzzy (struct rspamd_config *cfg) ctx = g_malloc0 (sizeof (struct rspamd_fuzzy_storage_ctx)); + ctx->magic = rspamd_fuzzy_storage_magic; ctx->sync_timeout = DEFAULT_SYNC_TIMEOUT; ctx->expire = DEFAULT_EXPIRE; ctx->keypair_cache_size = DEFAULT_KEYPAIR_CACHE_SIZE; diff --git a/src/hs_helper.c b/src/hs_helper.c index 5885461aa..1434f551a 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -39,11 +39,13 @@ worker_t hs_helper_worker = { static const gdouble default_max_time = 1.0; static const gdouble default_recompile_time = 60.0; +static const guint64 rspamd_hs_helper_magic = 0x22d310157a2288a0ULL; /* * Worker's context */ struct hs_helper_ctx { + guint64 magic; gchar *hs_dir; gboolean loaded; gdouble max_time; @@ -62,6 +64,7 @@ init_hs_helper (struct rspamd_config *cfg) type = g_quark_try_string ("hs_helper"); ctx = g_malloc0 (sizeof (*ctx)); + ctx->magic = rspamd_hs_helper_magic; ctx->cfg = cfg; ctx->hs_dir = RSPAMD_DBDIR "/"; ctx->max_time = default_max_time; diff --git a/src/http_proxy.c b/src/http_proxy.c index 3ad821f96..b61511d1c 100644 --- a/src/http_proxy.c +++ b/src/http_proxy.c @@ -49,7 +49,10 @@ struct rspamd_http_upstream { struct rspamd_cryptobox_pubkey *key; }; +static const guint64 rspamd_http_proxy_magic = 0xcdeb4fd1fc351980ULL; + struct http_proxy_ctx { + guint64 magic; gdouble timeout; struct timeval io_tv; struct rspamd_config *cfg; @@ -188,6 +191,7 @@ init_http_proxy (struct rspamd_config *cfg) type = g_quark_try_string ("http_proxy"); ctx = g_malloc0 (sizeof (struct http_proxy_ctx)); + ctx->magic = rspamd_http_proxy_magic; ctx->timeout = 5.0; ctx->upstreams = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal); ctx->rotate_tm = DEFAULT_ROTATION_TIME; diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 609f7995b..0774df13c 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -21,6 +21,7 @@ #include "message.h" #include "utlist.h" #include "http.h" +#include "worker_private.h" /* Max line size */ #define OUTBUFSIZ BUFSIZ diff --git a/src/lua_worker.c b/src/lua_worker.c index ea876cec5..87f597e28 100644 --- a/src/lua_worker.c +++ b/src/lua_worker.c @@ -47,10 +47,12 @@ worker_t lua_worker = { RSPAMD_WORKER_VER /* Version info */ }; +static const guint64 rspamd_lua_ctx_magic = 0x8055e2652aacf96eULL; /* * Worker's context */ struct rspamd_lua_worker_ctx { + guint64 magic; /* DNS resolver */ struct rspamd_dns_resolver *resolver; /* Events base */ @@ -310,6 +312,7 @@ init_lua_worker (struct rspamd_config *cfg) type = g_quark_try_string ("lua"); ctx = g_malloc0 (sizeof (struct rspamd_lua_worker_ctx)); + ctx->magic = rspamd_lua_ctx_magic; ctx->params = g_hash_table_new_full (rspamd_str_hash, rspamd_str_equal, g_free, diff --git a/src/rspamd.h b/src/rspamd.h index 90a4b3762..286a929f8 100644 --- a/src/rspamd.h +++ b/src/rspamd.h @@ -62,6 +62,11 @@ struct rspamd_worker { gpointer control_data; /**< used by control protocol to handle commands */ }; +struct rspamd_abstract_worker_ctx { + guint64 magic; + char data[]; +}; + struct rspamd_worker_signal_handler; struct rspamd_worker_signal_cb { diff --git a/src/smtp_proxy.c b/src/smtp_proxy.c index 3f9444b06..0202e3cfe 100644 --- a/src/smtp_proxy.c +++ b/src/smtp_proxy.c @@ -48,7 +48,10 @@ worker_t smtp_proxy_worker = { RSPAMD_WORKER_VER /* Version info */ }; +static guint64 rspamd_smtp_proxy_magic = 0xf3d849189c85f12dULL; + struct smtp_proxy_ctx { + guint64 magic; struct upstream_list *upstreams; gchar *upstreams_str; @@ -965,6 +968,7 @@ init_smtp_proxy (struct rspamd_config *cfg) type = g_quark_try_string ("smtp_proxy"); ctx = g_malloc0 (sizeof (struct smtp_worker_ctx)); + ctx->magic = rspamd_smtp_proxy_magic; ctx->pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); /* Set default values */ diff --git a/src/worker.c b/src/worker.c index a4ef7a81a..8056b3f0f 100644 --- a/src/worker.c +++ b/src/worker.c @@ -32,6 +32,7 @@ #include "libstat/stat_api.h" #include "libserver/worker_util.h" #include "libserver/rspamd_control.h" +#include "worker_private.h" #include "utlist.h" #include "lua/lua_common.h" @@ -70,44 +71,6 @@ worker_t normal_worker = { G_STRFUNC, \ __VA_ARGS__) -struct rspamd_worker_log_pipe { - gint fd; - enum rspamd_log_pipe_type type; - struct rspamd_worker_log_pipe *prev, *next; -}; - -/* - * Worker's context - */ -struct rspamd_worker_ctx { - guint32 timeout; - struct timeval io_tv; - /* Detect whether this worker is mime worker */ - gboolean is_mime; - /* HTTP worker */ - gboolean is_http; - /* JSON output */ - 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; - /* Log pipe */ - struct rspamd_worker_log_pipe *log_pipes; -}; - /* * Reduce number of tasks proceeded */ @@ -436,6 +399,7 @@ init_worker (struct rspamd_config *cfg) ctx = g_malloc0 (sizeof (struct rspamd_worker_ctx)); + ctx->magic = rspamd_worker_magic; ctx->is_mime = TRUE; ctx->timeout = DEFAULT_WORKER_IO_TIMEOUT; ctx->cfg = cfg; |