gboolean check_authed;
};
-static struct spf_ctx *spf_module_ctx = NULL;
+static inline struct spf_ctx *
+spf_get_context (struct rspamd_config *cfg)
+{
+ return (struct spf_ctx *)g_hash_table_lookup (cfg->c_modules, "spf");
+}
+
static void spf_symbol_callback (struct rspamd_task *task, void *unused);
gint
spf_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
- if (spf_module_ctx == NULL) {
- spf_module_ctx = g_malloc0 (sizeof (struct spf_ctx));
- }
+ struct spf_ctx *spf_module_ctx;
+ spf_module_ctx = rspamd_mempool_alloc0 (cfg->cfg_pool,
+ sizeof (*spf_module_ctx));
*ctx = (struct module_ctx *)spf_module_ctx;
rspamd_rcl_add_doc_by_path (cfg,
const ucl_object_t *value;
gint res = TRUE, cb_id;
guint cache_size;
+ struct spf_ctx *spf_module_ctx = spf_get_context (cfg);
if (!rspamd_config_is_module_enabled (cfg, "spf")) {
return TRUE;
msg_info_config ("init internal spf module");
+ rspamd_mempool_add_destructor (cfg->cfg_pool,
+ (rspamd_mempool_destruct_t)rspamd_lru_hash_destroy,
+ spf_module_ctx->spf_hash);
+ rspamd_mempool_add_destructor (cfg->cfg_pool,
+ (rspamd_mempool_destruct_t)rspamd_map_helper_destroy_radix,
+ spf_module_ctx->whitelist_ip);
+
return res;
}
gint
spf_module_reconfig (struct rspamd_config *cfg)
{
- struct module_ctx saved_ctx;
-
- saved_ctx = spf_module_ctx->ctx;
- rspamd_lru_hash_destroy (spf_module_ctx->spf_hash);
- rspamd_map_helper_destroy_radix (spf_module_ctx->whitelist_ip);
- memset (spf_module_ctx, 0, sizeof (*spf_module_ctx));
- spf_module_ctx->ctx = saved_ctx;
return spf_module_config (cfg);
}
gchar *spf_result;
guint af, mask, bmask, addrlen;
const gchar *spf_message, *spf_symbol;
+ struct spf_ctx *spf_module_ctx = spf_get_context (task->cfg);
if (task->from_addr == NULL) {
return FALSE;
{
struct spf_resolved *l;
struct rspamd_async_watcher *w = ud;
+ struct spf_ctx *spf_module_ctx = spf_get_context (task->cfg);
if (record && record->na) {
rspamd_task_insert_result (task,
struct spf_resolved *l;
struct rspamd_async_watcher *w;
gint *dmarc_checks;
+ struct spf_ctx *spf_module_ctx = spf_get_context (task->cfg);
/* Allow dmarc */
dmarc_checks = rspamd_mempool_get_variable (task->task_pool,