]> source.dussan.org Git - rspamd.git/commitdiff
Fix issues found
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 18 Nov 2015 15:19:36 +0000 (15:19 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 18 Nov 2015 15:19:36 +0000 (15:19 +0000)
src/libserver/cfg_utils.c
src/lua/lua_util.c
src/rspamadm/configdump.c
src/rspamadm/configtest.c
src/rspamadm/rspamadm.c
src/rspamd.c

index 5d0eb06ae9d4698d8e68e8bbaff87b5e9a572764..4146d51cb7b6224c9b53f51637cb7ac2a2745737 100644 (file)
@@ -199,6 +199,8 @@ rspamd_config_defaults (void)
        cfg->cache = rspamd_symbols_cache_new (cfg);
 
        REF_INIT_RETAIN (cfg, rspamd_config_free);
+
+       return cfg;
 }
 
 void
@@ -228,6 +230,7 @@ rspamd_config_free (struct rspamd_config *cfg)
        rspamd_symbols_cache_destroy (cfg->cache);
        REF_RELEASE (cfg->libs_ctx);
        rspamd_mempool_delete (cfg->cfg_pool);
+       g_slice_free1 (sizeof (*cfg), cfg);
 }
 
 const ucl_object_t *
index f0c9369bf9103dc81895769903f4365209a74ada..6a43206a5d6866c6b7620d0f7ec2585c0b21d8d0 100644 (file)
@@ -161,17 +161,14 @@ lua_util_load_rspamd_config (lua_State *L)
        cfg_name = luaL_checkstring (L, 1);
 
        if (cfg_name) {
-               cfg = g_malloc0 (sizeof (struct rspamd_config));
-               rspamd_init_cfg (cfg, FALSE);
-               cfg->cache = rspamd_symbols_cache_new (cfg);
+               cfg = rspamd_config_defaults ();
 
                if (rspamd_config_read (cfg, cfg_name, NULL, NULL, NULL, NULL)) {
                        msg_err_config ("cannot load config from %s", cfg_name);
                        lua_pushnil (L);
                }
                else {
-                       rspamd_config_post_load (cfg);
-                       rspamd_symbols_cache_init (cfg->cache);
+                       rspamd_config_post_load (cfg, FALSE);
                        pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
                        rspamd_lua_setclass (L, "rspamd{config}", -1);
                        *pcfg = cfg;
@@ -193,8 +190,8 @@ lua_util_config_from_ucl (lua_State *L)
 
        if (obj) {
                cfg = g_malloc0 (sizeof (struct rspamd_config));
-               rspamd_init_cfg (cfg, FALSE);
-               cfg->lua_state = L;
+               cfg = rspamd_config_defaults ();
+
                cfg->rcl_obj = obj;
                cfg->cache = rspamd_symbols_cache_new (cfg);
                top = rspamd_rcl_config_init ();
@@ -205,8 +202,7 @@ lua_util_config_from_ucl (lua_State *L)
                        lua_pushnil (L);
                }
                else {
-                       rspamd_config_post_load (cfg);
-                       rspamd_symbols_cache_init (cfg->cache);
+                       rspamd_config_post_load (cfg, FALSE);
                        pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
                        rspamd_lua_setclass (L, "rspamd{config}", -1);
                        *pcfg = cfg;
index d19d2da3301356e45dabe2e95b334d23248817c2..e40f2f34afe37e8dea93731ebe9c80b8234651d4 100644 (file)
@@ -173,25 +173,15 @@ rspamadm_configdump (gint argc, gchar **argv)
        }
        else {
                /* Do post-load actions */
-               rspamd_config_post_load (cfg);
+               rspamd_config_post_load (cfg, FALSE);
                ret = TRUE;
        }
 
        if (ret) {
-               rspamd_symbols_cache_init (rspamd_main->cfg->cache);
 
                if (!rspamd_init_filters (rspamd_main->cfg, FALSE)) {
                        ret = FALSE;
                }
-
-               /* Insert classifiers symbols */
-               (void) rspamd_config_insert_classify_symbols (rspamd_main->cfg);
-
-               if (!rspamd_symbols_cache_validate (rspamd_main->cfg->cache,
-                               rspamd_main->cfg,
-                               FALSE)) {
-                       ret = FALSE;
-               }
        }
 
        if (ret) {
index 1de6949759a3d970568b227620082be94efa136c..65f358f66d99ab8f34eb1693533bbdffe060e5b2 100644 (file)
@@ -150,25 +150,13 @@ rspamadm_configtest (gint argc, gchar **argv)
        }
        else {
                /* Do post-load actions */
-               rspamd_config_post_load (cfg);
-               ret = TRUE;
+               ret = rspamd_config_post_load (cfg, TRUE);
        }
 
        if (ret) {
-               rspamd_symbols_cache_init (rspamd_main->cfg->cache);
-
                if (!rspamd_init_filters (rspamd_main->cfg, FALSE)) {
                        ret = FALSE;
                }
-
-               /* Insert classifiers symbols */
-               (void) rspamd_config_insert_classify_symbols (rspamd_main->cfg);
-
-               if (!rspamd_symbols_cache_validate (rspamd_main->cfg->cache,
-                               rspamd_main->cfg,
-                               FALSE)) {
-                       ret = FALSE;
-               }
        }
 
        if (strict && ret) {
index c4ae62a4bd2f44d08bb788457fca954b8be63c7a..5751c50d0a619f562db357223dcf6342932dedf5 100644 (file)
@@ -208,10 +208,9 @@ main (gint argc, gchar **argv, gchar **env)
                rspamd_strcase_equal, g_free, g_free);
        ottery_init (NULL);
        process_quark = g_quark_from_static_string ("rspamadm");
-       cfg = g_malloc0 (sizeof (*cfg));
+       cfg = rspamd_config_defaults ();
+       cfg->libs_ctx = rspamd_init_libs ();
        rspamd_main = g_malloc0 (sizeof (*rspamd_main));
-       rspamd_init_libs ();
-       rspamd_init_cfg (cfg, TRUE);
        rspamd_main->cfg = cfg;
        rspamd_main->pid = getpid ();
        rspamd_main->type = process_quark;
index 3d42f2650400e16e7736f0adcf8f93556c1d099e..92b17b37e4beb08f71ff55865b5bc8f79114a90d 100644 (file)
@@ -270,7 +270,8 @@ reread_config (struct rspamd_main *rspamd_main)
 
        tmp_cfg = rspamd_config_defaults ();
        tmp_cfg->c_modules = g_hash_table_ref (rspamd_main->cfg->c_modules);
-       tmp_cfg->libs_ctx = REF_RETAIN (rspamd_main->cfg->libs_ctx);
+       tmp_cfg->libs_ctx = rspamd_main->cfg->libs_ctx;
+       REF_RETAIN (tmp_cfg->libs_ctx);
        rspamd_set_logger (tmp_cfg,  g_quark_try_string ("main"), rspamd_main);
        cfg_file = rspamd_mempool_strdup (tmp_cfg->cfg_pool,
                        rspamd_main->cfg->cfg_name);