|
71 | 71 | #include "storage/proc.h"
|
72 | 72 | #include "storage/procarray.h"
|
73 | 73 | #include "storage/procsignal.h"
|
| 74 | +#include "tcop/tcopprot.h" |
74 | 75 | #include "utils/acl.h"
|
75 | 76 | #include "utils/builtins.h"
|
76 | 77 | #include "utils/guc.h"
|
@@ -145,38 +146,6 @@ static void XLogWalRcvSendHSFeedback(bool immed);
|
145 | 146 | static void ProcessWalSndrMessage(XLogRecPtr walEnd, TimestampTz sendTime);
|
146 | 147 | static void WalRcvComputeNextWakeup(WalRcvWakeupReason reason, TimestampTz now);
|
147 | 148 |
|
148 |
| -/* |
149 |
| - * Process any interrupts the walreceiver process may have received. |
150 |
| - * This should be called any time the process's latch has become set. |
151 |
| - * |
152 |
| - * Currently, only SIGTERM is of interest. We can't just exit(1) within the |
153 |
| - * SIGTERM signal handler, because the signal might arrive in the middle of |
154 |
| - * some critical operation, like while we're holding a spinlock. Instead, the |
155 |
| - * signal handler sets a flag variable as well as setting the process's latch. |
156 |
| - * We must check the flag (by calling ProcessWalRcvInterrupts) anytime the |
157 |
| - * latch has become set. Operations that could block for a long time, such as |
158 |
| - * reading from a remote server, must pay attention to the latch too; see |
159 |
| - * libpqrcv_PQgetResult for example. |
160 |
| - */ |
161 |
| -void |
162 |
| -ProcessWalRcvInterrupts(void) |
163 |
| -{ |
164 |
| - /* |
165 |
| - * Although walreceiver interrupt handling doesn't use the same scheme as |
166 |
| - * regular backends, call CHECK_FOR_INTERRUPTS() to make sure we receive |
167 |
| - * any incoming signals on Win32, and also to make sure we process any |
168 |
| - * barrier events. |
169 |
| - */ |
170 |
| - CHECK_FOR_INTERRUPTS(); |
171 |
| - |
172 |
| - if (ShutdownRequestPending) |
173 |
| - { |
174 |
| - ereport(FATAL, |
175 |
| - (errcode(ERRCODE_ADMIN_SHUTDOWN), |
176 |
| - errmsg("terminating walreceiver process due to administrator command"))); |
177 |
| - } |
178 |
| -} |
179 |
| - |
180 | 149 |
|
181 | 150 | /* Main entry point for walreceiver process */
|
182 | 151 | void
|
@@ -280,7 +249,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
|
280 | 249 | pqsignal(SIGHUP, SignalHandlerForConfigReload); /* set flag to read config
|
281 | 250 | * file */
|
282 | 251 | pqsignal(SIGINT, SIG_IGN);
|
283 |
| - pqsignal(SIGTERM, SignalHandlerForShutdownRequest); /* request shutdown */ |
| 252 | + pqsignal(SIGTERM, die); /* request shutdown */ |
284 | 253 | /* SIGQUIT handler was already set up by InitPostmasterChild */
|
285 | 254 | pqsignal(SIGALRM, SIG_IGN);
|
286 | 255 | pqsignal(SIGPIPE, SIG_IGN);
|
@@ -459,7 +428,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
|
459 | 428 | errmsg("cannot continue WAL streaming, recovery has already ended")));
|
460 | 429 |
|
461 | 430 | /* Process any requests or signals received recently */
|
462 |
| - ProcessWalRcvInterrupts(); |
| 431 | + CHECK_FOR_INTERRUPTS(); |
463 | 432 |
|
464 | 433 | if (ConfigReloadPending)
|
465 | 434 | {
|
@@ -555,7 +524,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
|
555 | 524 | if (rc & WL_LATCH_SET)
|
556 | 525 | {
|
557 | 526 | ResetLatch(MyLatch);
|
558 |
| - ProcessWalRcvInterrupts(); |
| 527 | + CHECK_FOR_INTERRUPTS(); |
559 | 528 |
|
560 | 529 | if (walrcv->force_reply)
|
561 | 530 | {
|
@@ -704,7 +673,7 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
|
704 | 673 | {
|
705 | 674 | ResetLatch(MyLatch);
|
706 | 675 |
|
707 |
| - ProcessWalRcvInterrupts(); |
| 676 | + CHECK_FOR_INTERRUPTS(); |
708 | 677 |
|
709 | 678 | SpinLockAcquire(&walrcv->mutex);
|
710 | 679 | Assert(walrcv->walRcvState == WALRCV_RESTARTING ||
|
|
0 commit comments