@@ -78,10 +78,12 @@ static void chartable_url_symbol_callback (struct rspamd_task *task, void *unuse | |||
gint | |||
chartable_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) | |||
{ | |||
chartable_module_ctx = g_malloc (sizeof (struct chartable_ctx)); | |||
if (chartable_module_ctx == NULL) { | |||
chartable_module_ctx = g_malloc (sizeof (struct chartable_ctx)); | |||
chartable_module_ctx->chartable_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
chartable_module_ctx->max_word_len = 10; | |||
chartable_module_ctx->chartable_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
chartable_module_ctx->max_word_len = 10; | |||
} | |||
*ctx = (struct module_ctx *)chartable_module_ctx; | |||
@@ -115,16 +115,18 @@ dkim_module_key_dtor (gpointer k) | |||
gint | |||
dkim_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) | |||
{ | |||
dkim_module_ctx = g_malloc0 (sizeof (struct dkim_ctx)); | |||
dkim_module_ctx->dkim_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "dkim"); | |||
dkim_module_ctx->sign_headers = "from:sender:reply-to:subject:date:message-id:" | |||
"to:cc:mime-version:content-type:content-transfer-encoding:" | |||
"resent-to:resent-cc:resent-from:resent-sender:resent-message-id:" | |||
"in-reply-to:references:list-id:list-owner:list-unsubscribe:" | |||
"list-subscribe:list-post"; | |||
dkim_module_ctx->sign_condition_ref = -1; | |||
dkim_module_ctx->max_sigs = DEFAULT_MAX_SIGS; | |||
if (dkim_module_ctx == NULL) { | |||
dkim_module_ctx = g_malloc0 (sizeof (struct dkim_ctx)); | |||
dkim_module_ctx->dkim_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), "dkim"); | |||
dkim_module_ctx->sign_headers = "from:sender:reply-to:subject:date:message-id:" | |||
"to:cc:mime-version:content-type:content-transfer-encoding:" | |||
"resent-to:resent-cc:resent-from:resent-sender:resent-message-id:" | |||
"in-reply-to:references:list-id:list-owner:list-unsubscribe:" | |||
"list-subscribe:list-post"; | |||
dkim_module_ctx->sign_condition_ref = -1; | |||
dkim_module_ctx->max_sigs = DEFAULT_MAX_SIGS; | |||
} | |||
*ctx = (struct module_ctx *)dkim_module_ctx; | |||
@@ -637,13 +637,16 @@ fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) | |||
{ | |||
lua_State *L = cfg->lua_state; | |||
fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx)); | |||
if (fuzzy_module_ctx == NULL) { | |||
fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx)); | |||
fuzzy_module_ctx->fuzzy_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
/* TODO: this should match rules count actually */ | |||
fuzzy_module_ctx->keypairs_cache = rspamd_keypair_cache_new (32); | |||
fuzzy_module_ctx->fuzzy_rules = g_ptr_array_new (); | |||
} | |||
fuzzy_module_ctx->fuzzy_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
fuzzy_module_ctx->cfg = cfg; | |||
/* TODO: this should match rules count actually */ | |||
fuzzy_module_ctx->keypairs_cache = rspamd_keypair_cache_new (32); | |||
fuzzy_module_ctx->fuzzy_rules = g_ptr_array_new (); | |||
*ctx = (struct module_ctx *)fuzzy_module_ctx; | |||
@@ -1043,10 +1046,12 @@ fuzzy_check_module_reconfig (struct rspamd_config *cfg) | |||
saved_ctx = fuzzy_module_ctx->ctx; | |||
rspamd_mempool_delete (fuzzy_module_ctx->fuzzy_pool); | |||
rspamd_keypair_cache_destroy (fuzzy_module_ctx->keypairs_cache); | |||
g_ptr_array_free (fuzzy_module_ctx->fuzzy_rules, TRUE); | |||
memset (fuzzy_module_ctx, 0, sizeof (*fuzzy_module_ctx)); | |||
fuzzy_module_ctx->ctx = saved_ctx; | |||
fuzzy_module_ctx->fuzzy_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
fuzzy_module_ctx->cfg = cfg; | |||
fuzzy_module_ctx->fuzzy_rules = g_ptr_array_new (); | |||
fuzzy_module_ctx->keypairs_cache = rspamd_keypair_cache_new (32); | |||
return fuzzy_check_module_config (cfg); |
@@ -91,9 +91,10 @@ read_regexp_expression (rspamd_mempool_t * pool, | |||
gint | |||
regexp_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) | |||
{ | |||
regexp_module_ctx = g_malloc (sizeof (struct regexp_ctx)); | |||
regexp_module_ctx->regexp_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
if (regexp_module_ctx == NULL) { | |||
regexp_module_ctx = g_malloc (sizeof (struct regexp_ctx)); | |||
regexp_module_ctx->regexp_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
} | |||
*ctx = (struct module_ctx *)regexp_module_ctx; | |||
@@ -83,9 +83,11 @@ module_t spf_module = { | |||
gint | |||
spf_module_init (struct rspamd_config *cfg, struct module_ctx **ctx) | |||
{ | |||
spf_module_ctx = g_malloc (sizeof (struct spf_ctx)); | |||
if (spf_module_ctx == NULL) { | |||
spf_module_ctx = g_malloc (sizeof (struct spf_ctx)); | |||
spf_module_ctx->spf_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
spf_module_ctx->spf_pool = rspamd_mempool_new (rspamd_mempool_suggest_size (), NULL); | |||
} | |||
*ctx = (struct module_ctx *)spf_module_ctx; | |||