diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-24 19:55:37 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-24 19:56:05 +0100 |
commit | 25ef6b98215f5518dae638ce0fd6b4710f17b113 (patch) | |
tree | 3bd032e2097a3e65985bb10d1ae926498011086f /src/libserver | |
parent | bb638f7c7d851f20071f5f9ee77224c0173e73ae (diff) | |
download | rspamd-25ef6b98215f5518dae638ce0fd6b4710f17b113.tar.gz rspamd-25ef6b98215f5518dae638ce0fd6b4710f17b113.zip |
[Project] Rework rspamadm and Lua init path
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/cfg_file.h | 8 | ||||
-rw-r--r-- | src/libserver/cfg_utils.c | 13 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 520c847f3..777340e16 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -313,6 +313,7 @@ struct rspamd_config { gboolean enable_experimental; /**< Enable experimental plugins */ gboolean disable_pcre_jit; /**< Disable pcre JIT */ gboolean disable_lua_squeeze; /**< Disable lua rules squeezing */ + gboolean own_lua_state; /**< True if we have created lua_state internally */ gsize max_diff; /**< maximum diff size for text parts */ gsize max_cores_size; /**< maximum size occupied by rspamd core files */ @@ -445,11 +446,16 @@ struct rspamd_config { gboolean rspamd_parse_bind_line (struct rspamd_config *cfg, struct rspamd_worker_conf *cf, const gchar *str); + +enum rspamd_config_init_flags { + RSPAMD_CONFIG_INIT_DEFAULT = 0, + RSPAMD_CONFIG_INIT_SKIP_LUA = (1 << 0) +}; /** * Init default values * @param cfg config file */ -struct rspamd_config *rspamd_config_new (void); +struct rspamd_config *rspamd_config_new (enum rspamd_config_init_flags flags); /** * Free memory used by config structure diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index bf63b2188..e606139cf 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -114,7 +114,7 @@ rspamd_parse_bind_line (struct rspamd_config *cfg, } struct rspamd_config * -rspamd_config_new (void) +rspamd_config_new (enum rspamd_config_init_flags flags) { struct rspamd_config *cfg; @@ -172,7 +172,11 @@ rspamd_config_new (void) cfg->min_word_len = DEFAULT_MIN_WORD; cfg->max_word_len = DEFAULT_MAX_WORD; - cfg->lua_state = rspamd_lua_init (); + if (!(flags & RSPAMD_CONFIG_INIT_SKIP_LUA)) { + cfg->lua_state = rspamd_lua_init (); + cfg->own_lua_state = TRUE; + } + cfg->cache = rspamd_symbols_cache_new (cfg); cfg->ups_ctx = rspamd_upstreams_library_init (); cfg->re_cache = rspamd_re_cache_new (); @@ -251,7 +255,10 @@ rspamd_config_free (struct rspamd_config *cfg) rspamd_re_cache_unref (cfg->re_cache); rspamd_upstreams_library_unref (cfg->ups_ctx); rspamd_mempool_delete (cfg->cfg_pool); - lua_close (cfg->lua_state); + + if (cfg->lua_state && cfg->own_lua_state) { + lua_close (cfg->lua_state); + } REF_RELEASE (cfg->libs_ctx); DL_FOREACH_SAFE (cfg->log_pipes, lp, ltmp) { |