From 27d96df99900c5a62ab0fdf2a37565e78f256d6a Mon Sep 17 00:00:00 2001 From: rofl0r Date: Wed, 15 Jan 2020 16:35:43 +0000 Subject: [PATCH] remove duplicate code calling reload_config_file() as a side effect of not updating the config pointer when loading the config file fails, the "FIXME" level comment to take appropriate action in that case has been removed. the only issue remaining when receiving a SIGHUP and encountering a malformed config file would now be the case that output to syslog/logfile won't be resumed, if initially so configured. --- src/child.c | 7 ++----- src/main.c | 12 +++++------- src/main.h | 2 +- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/child.c b/src/child.c index 4a94b98..9ebba02 100644 --- a/src/child.c +++ b/src/child.c @@ -114,11 +114,8 @@ void child_main_loop (void) /* Handle log rotation if it was requested */ if (received_sighup) { - /* - * Ignore the return value of reload_config for now. - * This should actually be handled somehow... - */ - reload_config (); + + reload_config (1); #ifdef FILTER_ENABLE filter_reload (); diff --git a/src/main.c b/src/main.c index 4a5f8ea..71b6f91 100644 --- a/src/main.c +++ b/src/main.c @@ -244,21 +244,22 @@ change_user (const char *program) * convenience wrapper around reload_config_file * that also re-initializes logging. */ -int reload_config (void) +int reload_config (int reload_logging) { int ret; - shutdown_logging (); + if (reload_logging) shutdown_logging (); ret = reload_config_file (config_file, &config_main, &config_defaults); + if (ret != 0) { goto done; } config = &config_main; - ret = setup_logging (); + if (reload_logging) ret = setup_logging (); done: return ret; @@ -310,12 +311,9 @@ main (int argc, char **argv) initialize_config_defaults (&config_defaults); - if (reload_config_file (config_file, - &config_main, - &config_defaults)) { + if (reload_config(0)) { exit (EX_SOFTWARE); } - config = &config_main; init_stats (); diff --git a/src/main.h b/src/main.h index 5890d4a..d19a2f6 100644 --- a/src/main.h +++ b/src/main.h @@ -32,6 +32,6 @@ extern struct config_s *config; extern unsigned int received_sighup; /* boolean */ -extern int reload_config (void); +extern int reload_config (int reload_logging); #endif /* __MAIN_H__ */