repmgrd: always reopen log file after receiving SIGHUP

For whatever reason, since at least repmgr 2.0 the log file was only
ever reopened if a configuration file change took place.

GitHub #485.
This commit is contained in:
Ian Barwick
2018-08-02 10:51:18 +09:00
parent fb67b2cd4f
commit 3a789d53e0
4 changed files with 55 additions and 35 deletions

View File

@@ -2936,18 +2936,21 @@ handle_sighup(PGconn *conn)
{
close_connection(&conn);
conn = establish_db_connection(config_file_options.conninfo, true);
}
if (*config_file_options.log_file)
if (*config_file_options.log_file)
{
FILE *fd;
log_debug("reopening %s", config_file_options.log_file);
fd = freopen(config_file_options.log_file, "a", stderr);
if (fd == NULL)
{
FILE *fd;
fd = freopen(config_file_options.log_file, "a", stderr);
if (fd == NULL)
{
fprintf(stderr, "error reopening stderr to \"%s\": %s",
config_file_options.log_file, strerror(errno));
}
fprintf(stderr, "error reopening stderr to \"%s\": %s",
config_file_options.log_file, strerror(errno));
}
}
got_SIGHUP = false;
}