Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 635f580

Browse files
committed
Rename some signal and interrupt handling functions for consistency
The usual pattern for handling a signal is that the signal handler sets a flag and calls SetLatch(MyLatch), and CHECK_FOR_INTERRUPTS() or other code that is part of a wait loop calls another function to deal with it. The naming of the functions involved was a bit inconsistent, however. CHECK_FOR_INTERRUPTS() calls ProcessInterrupts() to do the heavy-lifting, but the analogous functions in aux processes were called HandleMainLoopInterrupts(), HandleStartupProcInterrupts(), etc. Similarly, most subroutines of ProcessInterrupts() were called Process*(), but some were called Handle*(). To make things less confusing, rename all the functions that are part of the overall signal/interrupt handling system but are not executed in a signal handler to e.g. ProcessSomething(), rather than HandleSomething(). The "Process" prefix is now consistently used in the non-signal-handler functions, and the "Handle" prefix in functions that are part of signal handlers, except for some completely unrelated functions that clearly have nothing to do with signal or interrupt handling. Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://www.postgresql.org/message-id/8a384b26-1499-41f6-be33-64b801fb98b8@iki.fi
1 parent f4e53e1 commit 635f580

File tree

16 files changed

+54
-54
lines changed

16 files changed

+54
-54
lines changed

src/backend/access/transam/parallel.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static const struct
158158
};
159159

160160
/* Private functions. */
161-
static void HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg);
161+
static void ProcessParallelMessage(ParallelContext *pcxt, int i, StringInfo msg);
162162
static void WaitForParallelWorkersToExit(ParallelContext *pcxt);
163163
static parallel_worker_main_type LookupParallelWorkerFunction(const char *libraryname, const char *funcname);
164164
static void ParallelWorkerShutdown(int code, Datum arg);
@@ -1031,7 +1031,7 @@ ParallelContextActive(void)
10311031
*
10321032
* Note: this is called within a signal handler! All we can do is set
10331033
* a flag that will cause the next CHECK_FOR_INTERRUPTS() to invoke
1034-
* HandleParallelMessages().
1034+
* ProcessParallelMessages().
10351035
*/
10361036
void
10371037
HandleParallelMessageInterrupt(void)
@@ -1042,10 +1042,10 @@ HandleParallelMessageInterrupt(void)
10421042
}
10431043

10441044
/*
1045-
* Handle any queued protocol messages received from parallel workers.
1045+
* Process any queued protocol messages received from parallel workers.
10461046
*/
10471047
void
1048-
HandleParallelMessages(void)
1048+
ProcessParallelMessages(void)
10491049
{
10501050
dlist_iter iter;
10511051
MemoryContext oldcontext;
@@ -1068,7 +1068,7 @@ HandleParallelMessages(void)
10681068
*/
10691069
if (hpm_context == NULL) /* first time through? */
10701070
hpm_context = AllocSetContextCreate(TopMemoryContext,
1071-
"HandleParallelMessages",
1071+
"ProcessParallelMessages",
10721072
ALLOCSET_DEFAULT_SIZES);
10731073
else
10741074
MemoryContextReset(hpm_context);
@@ -1111,7 +1111,7 @@ HandleParallelMessages(void)
11111111

11121112
initStringInfo(&msg);
11131113
appendBinaryStringInfo(&msg, data, nbytes);
1114-
HandleParallelMessage(pcxt, i, &msg);
1114+
ProcessParallelMessage(pcxt, i, &msg);
11151115
pfree(msg.data);
11161116
}
11171117
else
@@ -1131,10 +1131,10 @@ HandleParallelMessages(void)
11311131
}
11321132

11331133
/*
1134-
* Handle a single protocol message received from a single parallel worker.
1134+
* Process a single protocol message received from a single parallel worker.
11351135
*/
11361136
static void
1137-
HandleParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
1137+
ProcessParallelMessage(ParallelContext *pcxt, int i, StringInfo msg)
11381138
{
11391139
char msgtype;
11401140

src/backend/access/transam/xlogrecovery.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ PerformWalRecovery(void)
17741774
#endif
17751775

17761776
/* Handle interrupt signals of startup process */
1777-
HandleStartupProcInterrupts();
1777+
ProcessStartupProcInterrupts();
17781778

17791779
/*
17801780
* Pause WAL replay, if requested by a hot-standby session via
@@ -2949,7 +2949,7 @@ recoveryPausesHere(bool endOfRecovery)
29492949
/* loop until recoveryPauseState is set to RECOVERY_NOT_PAUSED */
29502950
while (GetRecoveryPauseState() != RECOVERY_NOT_PAUSED)
29512951
{
2952-
HandleStartupProcInterrupts();
2952+
ProcessStartupProcInterrupts();
29532953
if (CheckForStandbyTrigger())
29542954
return;
29552955

@@ -3038,7 +3038,7 @@ recoveryApplyDelay(XLogReaderState *record)
30383038
ResetLatch(&XLogRecoveryCtl->recoveryWakeupLatch);
30393039

30403040
/* This might change recovery_min_apply_delay. */
3041-
HandleStartupProcInterrupts();
3041+
ProcessStartupProcInterrupts();
30423042

30433043
if (CheckForStandbyTrigger())
30443044
break;
@@ -3727,7 +3727,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
37273727
now = GetCurrentTimestamp();
37283728

37293729
/* Handle interrupt signals of startup process */
3730-
HandleStartupProcInterrupts();
3730+
ProcessStartupProcInterrupts();
37313731
}
37323732
last_fail_time = now;
37333733
currentSource = XLOG_FROM_ARCHIVE;
@@ -4017,7 +4017,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
40174017
* This possibly-long loop needs to handle interrupts of startup
40184018
* process.
40194019
*/
4020-
HandleStartupProcInterrupts();
4020+
ProcessStartupProcInterrupts();
40214021
}
40224022

40234023
return XLREAD_FAIL; /* not reached */
@@ -4695,7 +4695,7 @@ RecoveryRequiresIntParameter(const char *param_name, int currValue, int minValue
46954695

46964696
while (GetRecoveryPauseState() != RECOVERY_NOT_PAUSED)
46974697
{
4698-
HandleStartupProcInterrupts();
4698+
ProcessStartupProcInterrupts();
46994699

47004700
if (CheckForStandbyTrigger())
47014701
{

src/backend/postmaster/autovacuum.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static WorkerInfo MyWorkerInfo = NULL;
316316
int AutovacuumLauncherPid = 0;
317317

318318
static Oid do_start_worker(void);
319-
static void HandleAutoVacLauncherInterrupts(void);
319+
static void ProcessAutoVacLauncherInterrupts(void);
320320
static void AutoVacLauncherShutdown(void) pg_attribute_noreturn();
321321
static void launcher_determine_sleep(bool canlaunch, bool recursing,
322322
struct timeval *nap);
@@ -594,7 +594,7 @@ AutoVacLauncherMain(const void *startup_data, size_t startup_data_len)
594594

595595
ResetLatch(MyLatch);
596596

597-
HandleAutoVacLauncherInterrupts();
597+
ProcessAutoVacLauncherInterrupts();
598598

599599
/*
600600
* a worker finished, or postmaster signaled failure to start a worker
@@ -742,7 +742,7 @@ AutoVacLauncherMain(const void *startup_data, size_t startup_data_len)
742742
* Process any new interrupts.
743743
*/
744744
static void
745-
HandleAutoVacLauncherInterrupts(void)
745+
ProcessAutoVacLauncherInterrupts(void)
746746
{
747747
/* the normal shutdown case */
748748
if (ShutdownRequestPending)

src/backend/postmaster/bgwriter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ BackgroundWriterMain(const void *startup_data, size_t startup_data_len)
226226
/* Clear any already-pending wakeups */
227227
ResetLatch(MyLatch);
228228

229-
HandleMainLoopInterrupts();
229+
ProcessMainLoopInterrupts();
230230

231231
/*
232232
* Do one cycle of dirty-buffer writing.

src/backend/postmaster/checkpointer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static pg_time_t last_xlog_switch_time;
157157

158158
/* Prototypes for private functions */
159159

160-
static void HandleCheckpointerInterrupts(void);
160+
static void ProcessCheckpointerInterrupts(void);
161161
static void CheckArchiveTimeout(void);
162162
static bool IsCheckpointOnSchedule(double progress);
163163
static bool ImmediateCheckpointRequested(void);
@@ -359,7 +359,7 @@ CheckpointerMain(const void *startup_data, size_t startup_data_len)
359359
*/
360360
AbsorbSyncRequests();
361361

362-
HandleCheckpointerInterrupts();
362+
ProcessCheckpointerInterrupts();
363363
if (ShutdownXLOGPending || ShutdownRequestPending)
364364
break;
365365

@@ -536,7 +536,7 @@ CheckpointerMain(const void *startup_data, size_t startup_data_len)
536536
* We may have received an interrupt during the checkpoint and the
537537
* latch might have been reset (e.g. in CheckpointWriteDelay).
538538
*/
539-
HandleCheckpointerInterrupts();
539+
ProcessCheckpointerInterrupts();
540540
if (ShutdownXLOGPending || ShutdownRequestPending)
541541
break;
542542
}
@@ -615,7 +615,7 @@ CheckpointerMain(const void *startup_data, size_t startup_data_len)
615615
/* Clear any already-pending wakeups */
616616
ResetLatch(MyLatch);
617617

618-
HandleCheckpointerInterrupts();
618+
ProcessCheckpointerInterrupts();
619619

620620
if (ShutdownRequestPending)
621621
break;
@@ -634,7 +634,7 @@ CheckpointerMain(const void *startup_data, size_t startup_data_len)
634634
* Process any new interrupts.
635635
*/
636636
static void
637-
HandleCheckpointerInterrupts(void)
637+
ProcessCheckpointerInterrupts(void)
638638
{
639639
if (ProcSignalBarrierPending)
640640
ProcessProcSignalBarrier();

src/backend/postmaster/interrupt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ volatile sig_atomic_t ShutdownRequestPending = false;
3131
* Simple interrupt handler for main loops of background processes.
3232
*/
3333
void
34-
HandleMainLoopInterrupts(void)
34+
ProcessMainLoopInterrupts(void)
3535
{
3636
if (ProcSignalBarrierPending)
3737
ProcessProcSignalBarrier();
@@ -55,7 +55,7 @@ HandleMainLoopInterrupts(void)
5555
*
5656
* Normally, this handler would be used for SIGHUP. The idea is that code
5757
* which uses it would arrange to check the ConfigReloadPending flag at
58-
* convenient places inside main loops, or else call HandleMainLoopInterrupts.
58+
* convenient places inside main loops, or else call ProcessMainLoopInterrupts.
5959
*/
6060
void
6161
SignalHandlerForConfigReload(SIGNAL_ARGS)
@@ -99,7 +99,7 @@ SignalHandlerForCrashExit(SIGNAL_ARGS)
9999
* SIGINT or SIGTERM.
100100
*
101101
* ShutdownRequestPending should be checked at a convenient place within the
102-
* main loop, or else the main loop should call HandleMainLoopInterrupts.
102+
* main loop, or else the main loop should call ProcessMainLoopInterrupts.
103103
*/
104104
void
105105
SignalHandlerForShutdownRequest(SIGNAL_ARGS)

src/backend/postmaster/pgarch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static bool pgarch_archiveXlog(char *xlog);
147147
static bool pgarch_readyXlog(char *xlog);
148148
static void pgarch_archiveDone(char *xlog);
149149
static void pgarch_die(int code, Datum arg);
150-
static void HandlePgArchInterrupts(void);
150+
static void ProcessPgArchInterrupts(void);
151151
static int ready_file_comparator(Datum a, Datum b, void *arg);
152152
static void LoadArchiveLibrary(void);
153153
static void pgarch_call_module_shutdown_cb(int code, Datum arg);
@@ -324,7 +324,7 @@ pgarch_MainLoop(void)
324324
time_to_stop = ready_to_stop;
325325

326326
/* Check for barrier events and config update */
327-
HandlePgArchInterrupts();
327+
ProcessPgArchInterrupts();
328328

329329
/*
330330
* If we've gotten SIGTERM, we normally just sit and do nothing until
@@ -415,7 +415,7 @@ pgarch_ArchiverCopyLoop(void)
415415
* we'll adopt a new setting for archive_command as soon as
416416
* possible, even if there is a backlog of files to be archived.
417417
*/
418-
HandlePgArchInterrupts();
418+
ProcessPgArchInterrupts();
419419

420420
/* Reset variables that might be set by the callback */
421421
arch_module_check_errdetail_string = NULL;
@@ -856,7 +856,7 @@ pgarch_die(int code, Datum arg)
856856
* shutdown request is different between those loops.
857857
*/
858858
static void
859-
HandlePgArchInterrupts(void)
859+
ProcessPgArchInterrupts(void)
860860
{
861861
if (ProcSignalBarrierPending)
862862
ProcessProcSignalBarrier();

src/backend/postmaster/startup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#ifndef USE_POSTMASTER_DEATH_SIGNAL
3939
/*
4040
* On systems that need to make a system call to find out if the postmaster has
41-
* gone away, we'll do so only every Nth call to HandleStartupProcInterrupts().
41+
* gone away, we'll do so only every Nth call to ProcessStartupProcInterrupts().
4242
* This only affects how long it takes us to detect the condition while we're
4343
* busy replaying WAL. Latch waits and similar which should react immediately
4444
* through the usual techniques.
@@ -149,9 +149,9 @@ StartupRereadConfig(void)
149149
StartupRequestWalReceiverRestart();
150150
}
151151

152-
/* Handle various signals that might be sent to the startup process */
152+
/* Process various signals that might be sent to the startup process */
153153
void
154-
HandleStartupProcInterrupts(void)
154+
ProcessStartupProcInterrupts(void)
155155
{
156156
#ifdef POSTMASTER_POLL_RATE_LIMIT
157157
static uint32 postmaster_poll_count = 0;

src/backend/postmaster/walsummarizer.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int wal_summary_keep_time = 10 * HOURS_PER_DAY * MINS_PER_HOUR;
145145

146146
static void WalSummarizerShutdown(int code, Datum arg);
147147
static XLogRecPtr GetLatestLSN(TimeLineID *tli);
148-
static void HandleWalSummarizerInterrupts(void);
148+
static void ProcessWalSummarizerInterrupts(void);
149149
static XLogRecPtr SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn,
150150
bool exact, XLogRecPtr switch_lsn,
151151
XLogRecPtr maximum_lsn);
@@ -356,7 +356,7 @@ WalSummarizerMain(const void *startup_data, size_t startup_data_len)
356356
MemoryContextReset(context);
357357

358358
/* Process any signals received recently. */
359-
HandleWalSummarizerInterrupts();
359+
ProcessWalSummarizerInterrupts();
360360

361361
/* If it's time to remove any old WAL summaries, do that now. */
362362
MaybeRemoveOldWalSummaries();
@@ -856,7 +856,7 @@ GetLatestLSN(TimeLineID *tli)
856856
* Interrupt handler for main loop of WAL summarizer process.
857857
*/
858858
static void
859-
HandleWalSummarizerInterrupts(void)
859+
ProcessWalSummarizerInterrupts(void)
860860
{
861861
if (ProcSignalBarrierPending)
862862
ProcessProcSignalBarrier();
@@ -1016,7 +1016,7 @@ SummarizeWAL(TimeLineID tli, XLogRecPtr start_lsn, bool exact,
10161016
XLogRecord *record;
10171017
uint8 rmid;
10181018

1019-
HandleWalSummarizerInterrupts();
1019+
ProcessWalSummarizerInterrupts();
10201020

10211021
/* We shouldn't go backward. */
10221022
Assert(summary_start_lsn <= xlogreader->EndRecPtr);
@@ -1503,7 +1503,7 @@ summarizer_read_local_xlog_page(XLogReaderState *state,
15031503
WALReadError errinfo;
15041504
SummarizerReadLocalXLogPrivate *private_data;
15051505

1506-
HandleWalSummarizerInterrupts();
1506+
ProcessWalSummarizerInterrupts();
15071507

15081508
private_data = (SummarizerReadLocalXLogPrivate *)
15091509
state->private_data;
@@ -1541,7 +1541,7 @@ summarizer_read_local_xlog_page(XLogReaderState *state,
15411541
* current timeline, so more data might show up. Delay here
15421542
* so we don't tight-loop.
15431543
*/
1544-
HandleWalSummarizerInterrupts();
1544+
ProcessWalSummarizerInterrupts();
15451545
summarizer_wait_for_wal();
15461546

15471547
/* Recheck end-of-WAL. */
@@ -1692,7 +1692,7 @@ MaybeRemoveOldWalSummaries(void)
16921692
XLogRecPtr oldest_lsn = InvalidXLogRecPtr;
16931693
TimeLineID selected_tli;
16941694

1695-
HandleWalSummarizerInterrupts();
1695+
ProcessWalSummarizerInterrupts();
16961696

16971697
/*
16981698
* Pick a timeline for which some summary files still exist on disk,
@@ -1711,7 +1711,7 @@ MaybeRemoveOldWalSummaries(void)
17111711
{
17121712
WalSummaryFile *ws = lfirst(lc);
17131713

1714-
HandleWalSummarizerInterrupts();
1714+
ProcessWalSummarizerInterrupts();
17151715

17161716
/* If it's not on this timeline, it's not time to consider it. */
17171717
if (selected_tli != ws->tli)

src/backend/postmaster/walwriter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ WalWriterMain(const void *startup_data, size_t startup_data_len)
239239
ResetLatch(MyLatch);
240240

241241
/* Process any signals received recently */
242-
HandleMainLoopInterrupts();
242+
ProcessMainLoopInterrupts();
243243

244244
/*
245245
* Do what we're here for; then, if XLogBackgroundFlush() found useful

0 commit comments

Comments
 (0)