aboutsummaryrefslogtreecommitdiffstats
path: root/src/rspamd.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-16 17:34:35 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-01-16 17:34:35 +0000
commit8cf07fdcdd243f7fff5e61093d3a10d29de132aa (patch)
tree867324149e70af0d463d74226b1f394b71676960 /src/rspamd.c
parent2991e3909d87eb266ab763e105e908ea13bf1129 (diff)
downloadrspamd-8cf07fdcdd243f7fff5e61093d3a10d29de132aa.tar.gz
rspamd-8cf07fdcdd243f7fff5e61093d3a10d29de132aa.zip
[Fix] Another try to fix descriptors leak
MFH: true
Diffstat (limited to 'src/rspamd.c')
-rw-r--r--src/rspamd.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/rspamd.c b/src/rspamd.c
index 499702262..158ad1185 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -249,9 +249,6 @@ config_logger (rspamd_mempool_t *pool, gpointer ud)
{
struct rspamd_main *rspamd_main = ud;
- rspamd_log_close_priv (rspamd_main->logger,
- rspamd_main->workers_uid, rspamd_main->workers_gid);
-
if (config_test) {
/* Explicitly set logger type to console in case of config testing */
rspamd_main->cfg->log_type = RSPAMD_LOG_CONSOLE;
@@ -277,8 +274,6 @@ reread_config (struct rspamd_main *rspamd_main)
tmp_cfg->c_modules = g_hash_table_ref (rspamd_main->cfg->c_modules);
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->logger, rspamd_main->server_pool);
cfg_file = rspamd_mempool_strdup (tmp_cfg->cfg_pool,
rspamd_main->cfg->cfg_name);
/* Save some variables */
@@ -286,23 +281,21 @@ reread_config (struct rspamd_main *rspamd_main)
if (!load_rspamd_config (rspamd_main, tmp_cfg, TRUE,
RSPAMD_CONFIG_INIT_VALIDATE|RSPAMD_CONFIG_INIT_SYMCACHE)) {
+ rspamd_log_close_priv (rspamd_main->logger,
+ rspamd_main->workers_uid,
+ rspamd_main->workers_gid);
rspamd_set_logger (rspamd_main->cfg, g_quark_try_string ("main"),
&rspamd_main->logger, rspamd_main->server_pool);
+ rspamd_log_open_priv (rspamd_main->logger,
+ rspamd_main->workers_uid,
+ rspamd_main->workers_gid);
msg_err_main ("cannot parse new config file, revert to old one");
REF_RELEASE (tmp_cfg);
}
else {
msg_debug_main ("replacing config");
REF_RELEASE (rspamd_main->cfg);
-
rspamd_main->cfg = tmp_cfg;
- rspamd_set_logger (tmp_cfg, g_quark_try_string ("main"),
- &rspamd_main->logger, rspamd_main->server_pool);
- /* Force debug log */
- if (is_debug) {
- rspamd_main->cfg->log_level = G_LOG_LEVEL_DEBUG;
- }
-
msg_info_main ("config has been reread successfully");
}
}
@@ -901,14 +894,14 @@ rspamd_hup_handler (gint signo, short what, gpointer arg)
{
struct rspamd_main *rspamd_main = arg;
- rspamd_log_reopen_priv (rspamd_main->logger,
- rspamd_main->workers_uid,
- rspamd_main->workers_gid);
msg_info_main ("rspamd "
RVERSION
" is restarting");
g_hash_table_foreach (rspamd_main->workers, kill_old_workers, NULL);
rspamd_map_remove_all (rspamd_main->cfg);
+ rspamd_log_close_priv (rspamd_main->logger,
+ rspamd_main->workers_uid,
+ rspamd_main->workers_gid);
reread_config (rspamd_main);
rspamd_check_core_limits (rspamd_main);
spawn_workers (rspamd_main, rspamd_main->ev_base);
@@ -1185,6 +1178,9 @@ main (gint argc, gchar **argv, gchar **env)
exit (EXIT_SUCCESS);
}
+ rspamd_log_close_priv (rspamd_main->logger, rspamd_main->workers_uid,
+ rspamd_main->workers_gid);
+
if (config_test || dump_cache) {
if (!load_rspamd_config (rspamd_main, rspamd_main->cfg, FALSE, 0)) {
exit (EXIT_FAILURE);