Use standard SIGHUP handler in syslogger.

Commit 1e53fe0e70 changed background processes so that they use
standard SIGHUP handler. Like that, this commit makes syslogger use
standard SIGHUP handler to simplify the code.

Author: Bharath Rupireddy
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/CALj2ACXPorUqePswDtOeM_s82v9RW32E1fYmOPZ5NuE+TWKj_A@mail.gmail.com
This commit is contained in:
Fujii Masao 2020-11-04 14:48:02 +09:00
parent 9f12a3b95d
commit 02d332297f
1 changed files with 4 additions and 17 deletions

View File

@ -39,6 +39,7 @@
#include "pgstat.h"
#include "pgtime.h"
#include "postmaster/fork_process.h"
#include "postmaster/interrupt.h"
#include "postmaster/postmaster.h"
#include "postmaster/syslogger.h"
#include "storage/dsm.h"
@ -123,7 +124,6 @@ static CRITICAL_SECTION sysloggerSection;
/*
* Flags set by interrupt handlers for later service in the main loop.
*/
static volatile sig_atomic_t got_SIGHUP = false;
static volatile sig_atomic_t rotation_requested = false;
@ -144,7 +144,6 @@ static unsigned int __stdcall pipeThread(void *arg);
static void logfile_rotate(bool time_based_rotation, int size_rotation_for);
static char *logfile_getname(pg_time_t timestamp, const char *suffix);
static void set_next_rotation_time(void);
static void sigHupHandler(SIGNAL_ARGS);
static void sigUsr1Handler(SIGNAL_ARGS);
static void update_metainfo_datafile(void);
@ -240,7 +239,7 @@ SysLoggerMain(int argc, char *argv[])
* broken backends...
*/
pqsignal(SIGHUP, sigHupHandler); /* set flag to read config file */
pqsignal(SIGHUP, SignalHandlerForConfigReload); /* set flag to read config file */
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, SIG_IGN);
pqsignal(SIGQUIT, SIG_IGN);
@ -324,9 +323,9 @@ SysLoggerMain(int argc, char *argv[])
/*
* Process any requests or signals received recently.
*/
if (got_SIGHUP)
if (ConfigReloadPending)
{
got_SIGHUP = false;
ConfigReloadPending = false;
ProcessConfigFile(PGC_SIGHUP);
/*
@ -1553,18 +1552,6 @@ RemoveLogrotateSignalFiles(void)
unlink(LOGROTATE_SIGNAL_FILE);
}
/* SIGHUP: set flag to reload config file */
static void
sigHupHandler(SIGNAL_ARGS)
{
int save_errno = errno;
got_SIGHUP = true;
SetLatch(MyLatch);
errno = save_errno;
}
/* SIGUSR1: set flag to rotate logfile */
static void
sigUsr1Handler(SIGNAL_ARGS)