aboutsummaryrefslogtreecommitdiffstats
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
parent3cb21a049f62dff157a1f33e7bbd928d181b9ce0 (diff)
downloadrspamd-cb17589a11f00d0c9efc2aa77cee0e4a50e9ddde.tar.gz
rspamd-cb17589a11f00d0c9efc2aa77cee0e4a50e9ddde.zip
Move more initialization to the common routines.
-rw-r--r--src/libserver/cfg_file.h7
-rw-r--r--src/libserver/cfg_rcl.c10
-rw-r--r--src/libserver/cfg_utils.c25
-rw-r--r--src/main.c27
4 files changed, 38 insertions, 31 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 25f19d216..e2543fea8 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -395,6 +395,13 @@ void rspamd_ucl_add_conf_variables (struct ucl_parser *parser);
*/
gboolean rspamd_init_filters (struct rspamd_config *cfg, bool reconfig);
+/**
+ * Init configuration file structure
+ * @param cfg
+ * @param init_lua
+ */
+void rspamd_init_cfg (struct rspamd_config *cfg, gboolean init_lua);
+
#endif /* ifdef CFG_FILE_H */
/*
* vi:ts=4
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 19b920c69..ad0ed8bc3 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -2256,10 +2256,12 @@ rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
top = rspamd_rcl_config_init ();
err = NULL;
- HASH_FIND_STR (top, "logging", logger);
- if (logger != NULL) {
- logger->fin = logger_fin;
- logger->fin_ud = logger_ud;
+ if (logger_fin != NULL) {
+ HASH_FIND_STR (top, "logging", logger);
+ if (logger != NULL) {
+ logger->fin = logger_fin;
+ logger->fin_ud = logger_ud;
+ }
}
if (!rspamd_rcl_parse (top, cfg, cfg->cfg_pool, cfg->rcl_obj, &err)) {
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);
+}
diff --git a/src/main.c b/src/main.c
index 0b0a5628c..4d541c4e4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,7 +60,6 @@ static struct rspamd_worker * fork_worker (struct rspamd_main *,
static gboolean load_rspamd_config (struct rspamd_config *cfg,
gboolean init_modules);
static void init_cfg_cache (struct rspamd_config *cfg);
-static void rspamd_init_cfg (struct rspamd_config *cfg);
sig_atomic_t do_restart = 0;
sig_atomic_t do_reopen_log = 0;
@@ -362,7 +361,8 @@ reread_config (struct rspamd_main *rspamd)
tmp_cfg = (struct rspamd_config *)g_malloc0 (sizeof (struct rspamd_config));
if (tmp_cfg) {
- rspamd_init_cfg (tmp_cfg);
+ rspamd_init_cfg (tmp_cfg, FALSE);
+ tmp_cfg->lua_state = rspamd->cfg->lua_state;
cfg_file = rspamd_mempool_strdup (tmp_cfg->cfg_pool,
rspamd->cfg->cfg_name);
/* Save some variables */
@@ -1029,27 +1029,6 @@ perform_configs_sign (void)
}
static void
-rspamd_init_cfg (struct rspamd_config *cfg)
-{
- cfg->cfg_pool = rspamd_mempool_new (
- rspamd_mempool_suggest_size ());
- rspamd_config_defaults (cfg);
-
- 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);
-}
-
-static void
rspamd_init_main (struct rspamd_main *rspamd)
{
rspamd->server_pool = rspamd_mempool_new (
@@ -1094,7 +1073,7 @@ main (gint argc, gchar **argv, gchar **env)
rspamd_init_libs ();
rspamd_init_main (rspamd_main);
- rspamd_init_cfg (rspamd_main->cfg);
+ rspamd_init_cfg (rspamd_main->cfg, TRUE);
memset (&signals, 0, sizeof (struct sigaction));