From 17d3733be36b0daabda1bdb19a3c4452a360d8f9 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Wed, 26 Jan 2022 12:13:22 +0000 Subject: [PATCH] main: fix logging being disabled after reload conf fails fixes #417 --- src/main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 1309284..e8c9c07 100644 --- a/src/main.c +++ b/src/main.c @@ -254,7 +254,7 @@ change_user (const char *program) */ int reload_config (int reload_logging) { - int ret; + int ret, ret2; struct config_s *c_next = get_next_config(); log_message (LOG_NOTICE, "Reloading config file"); @@ -263,18 +263,19 @@ int reload_config (int reload_logging) ret = reload_config_file (config_file, c_next); - if (ret != 0) { - goto done; + if (ret == 0) { + if(config) free_config (config); + config = c_next; } - if(config) free_config (config); - config = c_next; + if (reload_logging) ret2 = setup_logging (); - if (reload_logging) ret = setup_logging (); - log_message (LOG_NOTICE, "Reloading config file finished"); + if (ret != 0) + log_message (LOG_WARNING, "Reloading config file failed!"); + else + log_message (LOG_NOTICE, "Reloading config file finished"); -done: - return ret; + return ret ? ret : ret2; } static void setup_sig(int sig, signal_func *sigh,