]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix C modules initialization on restart.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 10 Oct 2014 22:41:34 +0000 (23:41 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 10 Oct 2014 22:41:34 +0000 (23:41 +0100)
src/libserver/cfg_utils.c
src/main.c

index f7285d5ed033eba11daa45d8347501fb4931847f..ed764a9ef0562cb3e382a02d088745571e390dcf 100644 (file)
@@ -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);
index 84b6118224ff56a5991eedff452ef496b571567a..d4bd66b788b3a33e12291a794e8deac7663821bf 100644 (file)
@@ -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,