From 45c36aab4a2b1c66967320688ffc9ee916032abc Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Wed, 7 Oct 2020 07:09:35 +0530 Subject: [PATCH v1] walreceiver use standard SIGTERM handler Replace WalRcvShutdownHandler() with standard SignalHandlerForShutdownRequest(). --- src/backend/replication/walreceiver.c | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index bb1d44ccb7..65f933898d 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -109,7 +109,6 @@ static XLogSegNo recvSegNo = 0; * main loop. */ static volatile sig_atomic_t got_SIGHUP = false; -static volatile sig_atomic_t got_SIGTERM = false; /* * LogstreamResult indicates the byte positions that we have already @@ -137,8 +136,6 @@ static void ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime); /* Signal handlers */ static void WalRcvSigHupHandler(SIGNAL_ARGS); -static void WalRcvShutdownHandler(SIGNAL_ARGS); - /* * Process any interrupts the walreceiver process may have received. @@ -164,7 +161,7 @@ ProcessWalRcvInterrupts(void) */ CHECK_FOR_INTERRUPTS(); - if (got_SIGTERM) + if (ShutdownRequestPending) { ereport(FATAL, (errcode(ERRCODE_ADMIN_SHUTDOWN), @@ -269,7 +266,7 @@ WalReceiverMain(void) /* Properly accept or ignore signals the postmaster might send us */ pqsignal(SIGHUP, WalRcvSigHupHandler); /* set flag to read config file */ pqsignal(SIGINT, SIG_IGN); - pqsignal(SIGTERM, WalRcvShutdownHandler); /* request shutdown */ + pqsignal(SIGTERM, SignalHandlerForShutdownRequest); /* request shutdown */ /* SIGQUIT handler was already set up by InitPostmasterChild */ pqsignal(SIGALRM, SIG_IGN); pqsignal(SIGPIPE, SIG_IGN); @@ -813,21 +810,6 @@ WalRcvSigHupHandler(SIGNAL_ARGS) got_SIGHUP = true; } - -/* SIGTERM: set flag for ProcessWalRcvInterrupts */ -static void -WalRcvShutdownHandler(SIGNAL_ARGS) -{ - int save_errno = errno; - - got_SIGTERM = true; - - if (WalRcv->latch) - SetLatch(WalRcv->latch); - - errno = save_errno; -} - /* * Accept the message from XLOG stream, and process it. */ -- 2.25.1