1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

Use PostgresSigHupHandler in more places.

There seems to be no reason for every background process to have
its own flag indicating that a config-file reload is needed.
Instead, let's just use ConfigFilePending for that purpose
everywhere.

Patch by me, reviewed by Andres Freund and Daniel Gustafsson.

Discussion: http://postgr.es/m/CA+TgmoZwDk=BguVDVa+qdA6SBKef=PKbaKDQALTC_9qoz1mJqg@mail.gmail.com
This commit is contained in:
Robert Haas
2019-12-17 13:03:57 -05:00
parent 5910d6c7e3
commit 1e53fe0e70
8 changed files with 37 additions and 156 deletions

View File

@ -83,7 +83,6 @@ static time_t last_sigterm_time = 0;
/*
* 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 got_SIGTERM = false;
static volatile sig_atomic_t wakened = false;
static volatile sig_atomic_t ready_to_stop = false;
@ -98,7 +97,6 @@ static pid_t pgarch_forkexec(void);
NON_EXEC_STATIC void PgArchiverMain(int argc, char *argv[]) pg_attribute_noreturn();
static void pgarch_exit(SIGNAL_ARGS);
static void ArchSigHupHandler(SIGNAL_ARGS);
static void ArchSigTermHandler(SIGNAL_ARGS);
static void pgarch_waken(SIGNAL_ARGS);
static void pgarch_waken_stop(SIGNAL_ARGS);
@ -229,7 +227,7 @@ PgArchiverMain(int argc, char *argv[])
* Ignore all signals usually bound to some action in the postmaster,
* except for SIGHUP, SIGTERM, SIGUSR1, SIGUSR2, and SIGQUIT.
*/
pqsignal(SIGHUP, ArchSigHupHandler);
pqsignal(SIGHUP, PostgresSigHupHandler);
pqsignal(SIGINT, SIG_IGN);
pqsignal(SIGTERM, ArchSigTermHandler);
pqsignal(SIGQUIT, pgarch_exit);
@ -259,19 +257,6 @@ pgarch_exit(SIGNAL_ARGS)
exit(1);
}
/* SIGHUP signal handler for archiver process */
static void
ArchSigHupHandler(SIGNAL_ARGS)
{
int save_errno = errno;
/* set flag to re-read config file at next convenient time */
got_SIGHUP = true;
SetLatch(MyLatch);
errno = save_errno;
}
/* SIGTERM signal handler for archiver process */
static void
ArchSigTermHandler(SIGNAL_ARGS)
@ -348,9 +333,9 @@ pgarch_MainLoop(void)
time_to_stop = ready_to_stop;
/* Check for config update */
if (got_SIGHUP)
if (ConfigReloadPending)
{
got_SIGHUP = false;
ConfigReloadPending = false;
ProcessConfigFile(PGC_SIGHUP);
}
@ -457,9 +442,9 @@ pgarch_ArchiverCopyLoop(void)
* setting for archive_command as soon as possible, even if there
* is a backlog of files to be archived.
*/
if (got_SIGHUP)
if (ConfigReloadPending)
{
got_SIGHUP = false;
ConfigReloadPending = false;
ProcessConfigFile(PGC_SIGHUP);
}