From 7dbfea3c455e83a77213a92b9dfdc1c0577441ea Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 17 Dec 2019 13:14:28 -0500 Subject: Partially deduplicate interrupt handling for background processes. Where possible, share signal handler code and main loop interrupt checking. This saves quite a bit of code and should simplify maintenance, too. This commit intends not to change the way anything works, even though that might allow more code to be unified. It does unify a bunch of individual variables into a ShutdownRequestPending flag that has is now used by a bunch of different process types, though. Patch by me, reviewed by Andres Freund and Daniel Gustafsson. Discussion: http://postgr.es/m/CA+TgmoZwDk=BguVDVa+qdA6SBKef=PKbaKDQALTC_9qoz1mJqg@mail.gmail.com --- src/backend/tcop/postgres.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 0b7bc1fd030..ef5a9529689 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -58,6 +58,7 @@ #include "pg_trace.h" #include "pgstat.h" #include "postmaster/autovacuum.h" +#include "postmaster/interrupt.h" #include "postmaster/postmaster.h" #include "replication/logicallauncher.h" #include "replication/logicalworker.h" @@ -2861,24 +2862,6 @@ FloatExceptionHandler(SIGNAL_ARGS) "invalid operation, such as division by zero."))); } -/* - * SIGHUP: set flag to re-read config file at next convenient time. - * - * Sets the ConfigReloadPending flag, which should be checked at convenient - * places inside main loops. (Better than doing the reading in the signal - * handler, ey?) - */ -void -PostgresSigHupHandler(SIGNAL_ARGS) -{ - int save_errno = errno; - - ConfigReloadPending = true; - SetLatch(MyLatch); - - errno = save_errno; -} - /* * RecoveryConflictInterrupt: out-of-line portion of recovery conflict * handling following receipt of SIGUSR1. Designed to be similar to die() @@ -3827,8 +3810,7 @@ PostgresMain(int argc, char *argv[], WalSndSignals(); else { - pqsignal(SIGHUP, PostgresSigHupHandler); /* set flag to read config - * file */ + pqsignal(SIGHUP, SignalHandlerForConfigReload); pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */ pqsignal(SIGTERM, die); /* cancel current query and exit */ -- cgit v1.2.3