cfg->cache = rspamd_symbols_cache_new (cfg);
REF_INIT_RETAIN (cfg, rspamd_config_free);
+
+ return cfg;
}
void
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 *
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;
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 ();
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;
}
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) {
}
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) {
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;
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);