main: fix logging being disabled after reload conf fails

fixes #417
This commit is contained in:
rofl0r 2022-01-26 12:13:22 +00:00
parent 79d0b0fa79
commit 17d3733be3

View File

@ -254,7 +254,7 @@ change_user (const char *program)
*/ */
int reload_config (int reload_logging) int reload_config (int reload_logging)
{ {
int ret; int ret, ret2;
struct config_s *c_next = get_next_config(); struct config_s *c_next = get_next_config();
log_message (LOG_NOTICE, "Reloading config file"); 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); ret = reload_config_file (config_file, c_next);
if (ret != 0) { if (ret == 0) {
goto done; if(config) free_config (config);
config = c_next;
} }
if(config) free_config (config); if (reload_logging) ret2 = setup_logging ();
config = c_next;
if (reload_logging) ret = setup_logging (); if (ret != 0)
log_message (LOG_NOTICE, "Reloading config file finished"); log_message (LOG_WARNING, "Reloading config file failed!");
else
log_message (LOG_NOTICE, "Reloading config file finished");
done: return ret ? ret : ret2;
return ret;
} }
static void setup_sig(int sig, signal_func *sigh, static void setup_sig(int sig, signal_func *sigh,