From: Vsevolod Stakhov Date: Fri, 10 Oct 2014 22:41:34 +0000 (+0100) Subject: Fix C modules initialization on restart. X-Git-Tag: 0.7.2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43fabec7e1b1db64bf6d36839f601f18da7bda91;p=thirdparty%2Frspamd.git Fix C modules initialization on restart. --- diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index f7285d5ed0..ed764a9ef0 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -330,7 +330,9 @@ rspamd_config_defaults (struct rspamd_config *cfg) cfg->max_diff = 20480; cfg->metrics = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); - cfg->c_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); + if (cfg->c_modules == NULL) { + cfg->c_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); + } cfg->composite_symbols = g_hash_table_new (rspamd_str_hash, rspamd_str_equal); cfg->classifiers_symbols = g_hash_table_new (rspamd_str_hash, @@ -354,7 +356,6 @@ rspamd_config_free (struct rspamd_config *cfg) ucl_obj_unref (cfg->rcl_obj); g_hash_table_remove_all (cfg->metrics); g_hash_table_unref (cfg->metrics); - g_hash_table_remove_all (cfg->c_modules); g_hash_table_unref (cfg->c_modules); g_hash_table_remove_all (cfg->composite_symbols); g_hash_table_unref (cfg->composite_symbols); diff --git a/src/main.c b/src/main.c index 84b6118224..d4bd66b788 100644 --- a/src/main.c +++ b/src/main.c @@ -408,6 +408,8 @@ reread_config (struct rspamd_main *rspamd) /* Save some variables */ tmp_cfg->cfg_name = cfg_file; + tmp_cfg->c_modules = g_hash_table_ref (rspamd->cfg->c_modules); + if (!load_rspamd_config (tmp_cfg, FALSE)) { rspamd_set_logger (rspamd_main->cfg, g_quark_try_string ( "main"), rspamd_main); @@ -852,9 +854,7 @@ load_rspamd_config (struct rspamd_config *cfg, gboolean init_modules) while (l) { filt = l->data; if (filt->module) { - cur_module = - rspamd_mempool_alloc (cfg->cfg_pool, - sizeof (struct module_ctx)); + cur_module = g_slice_alloc0 (sizeof (struct module_ctx)); if (filt->module->module_init_func (cfg, &cur_module) == 0) { g_hash_table_insert (cfg->c_modules, (gpointer) filt->module->name,