aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_utils.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-17 15:28:48 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-17 15:28:48 +0100
commitcb17589a11f00d0c9efc2aa77cee0e4a50e9ddde (patch)
treeec5d3ff5e4692b125f295cfead06e79374534478 /src/libserver/cfg_utils.c
parent3cb21a049f62dff157a1f33e7bbd928d181b9ce0 (diff)
downloadrspamd-cb17589a11f00d0c9efc2aa77cee0e4a50e9ddde.tar.gz
rspamd-cb17589a11f00d0c9efc2aa77cee0e4a50e9ddde.zip
Move more initialization to the common routines.
Diffstat (limited to 'src/libserver/cfg_utils.c')
-rw-r--r--src/libserver/cfg_utils.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 28310da57..444ad9a11 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -871,6 +871,25 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
return rspamd_init_lua_filters (cfg);
}
-/*
- * vi:ts=4
- */
+void
+rspamd_init_cfg (struct rspamd_config *cfg, gboolean init_lua)
+{
+ cfg->cfg_pool = rspamd_mempool_new (
+ rspamd_mempool_suggest_size ());
+ rspamd_config_defaults (cfg);
+
+ if (init_lua) {
+ cfg->lua_state = rspamd_lua_init (cfg);
+ rspamd_mempool_add_destructor (cfg->cfg_pool,
+ (rspamd_mempool_destruct_t)lua_close, cfg->lua_state);
+ }
+
+ /* Pre-init of cache */
+ cfg->cache = g_new0 (struct symbols_cache, 1);
+ cfg->cache->static_pool = rspamd_mempool_new (
+ rspamd_mempool_suggest_size ());
+ cfg->cache->cfg = cfg;
+ cfg->cache->items_by_symbol = g_hash_table_new (
+ rspamd_str_hash,
+ rspamd_str_equal);
+}