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

Commit 1e285a5

Browse files
Remove Start* macros in postmaster.c.
These macros are just shorthands for calling StartChildProcess() with the appropriate process type, and they arguably make the code harder to understand. Suggested-by: Andres Freund Author: Reid Thompson Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/e88934c02a5c66f5e8caab2025f85da6b9026d0b.camel%40crunchydata.com
1 parent a39f1a3 commit 1e285a5

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,6 @@ static void ShmemBackendArrayAdd(Backend *bn);
561561
static void ShmemBackendArrayRemove(Backend *bn);
562562
#endif /* EXEC_BACKEND */
563563

564-
#define StartupDataBase() StartChildProcess(StartupProcess)
565-
#define StartArchiver() StartChildProcess(ArchiverProcess)
566-
#define StartBackgroundWriter() StartChildProcess(BgWriterProcess)
567-
#define StartCheckpointer() StartChildProcess(CheckpointerProcess)
568-
#define StartWalWriter() StartChildProcess(WalWriterProcess)
569-
#define StartWalReceiver() StartChildProcess(WalReceiverProcess)
570-
#define StartWalSummarizer() StartChildProcess(WalSummarizerProcess)
571-
572564
/* Macros to check exit status of a child process */
573565
#define EXIT_STATUS_0(st) ((st) == 0)
574566
#define EXIT_STATUS_1(st) (WIFEXITED(st) && WEXITSTATUS(st) == 1)
@@ -1457,14 +1449,14 @@ PostmasterMain(int argc, char *argv[])
14571449

14581450
/* Start bgwriter and checkpointer so they can help with recovery */
14591451
if (CheckpointerPID == 0)
1460-
CheckpointerPID = StartCheckpointer();
1452+
CheckpointerPID = StartChildProcess(CheckpointerProcess);
14611453
if (BgWriterPID == 0)
1462-
BgWriterPID = StartBackgroundWriter();
1454+
BgWriterPID = StartChildProcess(BgWriterProcess);
14631455

14641456
/*
14651457
* We're ready to rock and roll...
14661458
*/
1467-
StartupPID = StartupDataBase();
1459+
StartupPID = StartChildProcess(StartupProcess);
14681460
Assert(StartupPID != 0);
14691461
StartupStatus = STARTUP_RUNNING;
14701462
pmState = PM_STARTUP;
@@ -1798,9 +1790,9 @@ ServerLoop(void)
17981790
pmState == PM_HOT_STANDBY || pmState == PM_STARTUP)
17991791
{
18001792
if (CheckpointerPID == 0)
1801-
CheckpointerPID = StartCheckpointer();
1793+
CheckpointerPID = StartChildProcess(CheckpointerProcess);
18021794
if (BgWriterPID == 0)
1803-
BgWriterPID = StartBackgroundWriter();
1795+
BgWriterPID = StartChildProcess(BgWriterProcess);
18041796
}
18051797

18061798
/*
@@ -1809,7 +1801,7 @@ ServerLoop(void)
18091801
* be writing any new WAL).
18101802
*/
18111803
if (WalWriterPID == 0 && pmState == PM_RUN)
1812-
WalWriterPID = StartWalWriter();
1804+
WalWriterPID = StartChildProcess(WalWriterProcess);
18131805

18141806
/*
18151807
* If we have lost the autovacuum launcher, try to start a new one. We
@@ -1828,7 +1820,7 @@ ServerLoop(void)
18281820

18291821
/* If we have lost the archiver, try to start a new one. */
18301822
if (PgArchPID == 0 && PgArchStartupAllowed())
1831-
PgArchPID = StartArchiver();
1823+
PgArchPID = StartChildProcess(ArchiverProcess);
18321824

18331825
/* If we need to signal the autovacuum launcher, do so now */
18341826
if (avlauncher_needs_signal)
@@ -3019,11 +3011,11 @@ process_pm_child_exit(void)
30193011
* if this fails, we'll just try again later.
30203012
*/
30213013
if (CheckpointerPID == 0)
3022-
CheckpointerPID = StartCheckpointer();
3014+
CheckpointerPID = StartChildProcess(CheckpointerProcess);
30233015
if (BgWriterPID == 0)
3024-
BgWriterPID = StartBackgroundWriter();
3016+
BgWriterPID = StartChildProcess(BgWriterProcess);
30253017
if (WalWriterPID == 0)
3026-
WalWriterPID = StartWalWriter();
3018+
WalWriterPID = StartChildProcess(WalWriterProcess);
30273019
MaybeStartWalSummarizer();
30283020

30293021
/*
@@ -3033,7 +3025,7 @@ process_pm_child_exit(void)
30333025
if (!IsBinaryUpgrade && AutoVacuumingActive() && AutoVacPID == 0)
30343026
AutoVacPID = StartAutoVacLauncher();
30353027
if (PgArchStartupAllowed() && PgArchPID == 0)
3036-
PgArchPID = StartArchiver();
3028+
PgArchPID = StartChildProcess(ArchiverProcess);
30373029

30383030
/* workers may be scheduled to start now */
30393031
maybe_start_bgworkers();
@@ -3188,7 +3180,7 @@ process_pm_child_exit(void)
31883180
HandleChildCrash(pid, exitstatus,
31893181
_("archiver process"));
31903182
if (PgArchStartupAllowed())
3191-
PgArchPID = StartArchiver();
3183+
PgArchPID = StartChildProcess(ArchiverProcess);
31923184
continue;
31933185
}
31943186

@@ -3767,7 +3759,7 @@ PostmasterStateMachine(void)
37673759
Assert(Shutdown > NoShutdown);
37683760
/* Start the checkpointer if not running */
37693761
if (CheckpointerPID == 0)
3770-
CheckpointerPID = StartCheckpointer();
3762+
CheckpointerPID = StartChildProcess(CheckpointerProcess);
37713763
/* And tell it to shut down */
37723764
if (CheckpointerPID != 0)
37733765
{
@@ -3899,7 +3891,7 @@ PostmasterStateMachine(void)
38993891

39003892
/*
39013893
* If we need to recover from a crash, wait for all non-syslogger children
3902-
* to exit, then reset shmem and StartupDataBase.
3894+
* to exit, then reset shmem and start the startup process.
39033895
*/
39043896
if (FatalError && pmState == PM_NO_CHILDREN)
39053897
{
@@ -3921,7 +3913,7 @@ PostmasterStateMachine(void)
39213913
/* re-create shared memory and semaphores */
39223914
CreateSharedMemoryAndSemaphores();
39233915

3924-
StartupPID = StartupDataBase();
3916+
StartupPID = StartChildProcess(StartupProcess);
39253917
Assert(StartupPID != 0);
39263918
StartupStatus = STARTUP_RUNNING;
39273919
pmState = PM_STARTUP;
@@ -5066,7 +5058,7 @@ process_pm_pmsignal(void)
50665058
*/
50675059
Assert(PgArchPID == 0);
50685060
if (XLogArchivingAlways())
5069-
PgArchPID = StartArchiver();
5061+
PgArchPID = StartChildProcess(ArchiverProcess);
50705062

50715063
/*
50725064
* If we aren't planning to enter hot standby mode later, treat
@@ -5501,7 +5493,7 @@ MaybeStartWalReceiver(void)
55015493
pmState == PM_HOT_STANDBY) &&
55025494
Shutdown <= SmartShutdown)
55035495
{
5504-
WalReceiverPID = StartWalReceiver();
5496+
WalReceiverPID = StartChildProcess(WalReceiverProcess);
55055497
if (WalReceiverPID != 0)
55065498
WalReceiverRequested = false;
55075499
/* else leave the flag set, so we'll try again later */
@@ -5518,7 +5510,7 @@ MaybeStartWalSummarizer(void)
55185510
if (summarize_wal && WalSummarizerPID == 0 &&
55195511
(pmState == PM_RUN || pmState == PM_HOT_STANDBY) &&
55205512
Shutdown <= SmartShutdown)
5521-
WalSummarizerPID = StartWalSummarizer();
5513+
WalSummarizerPID = StartChildProcess(WalSummarizerProcess);
55225514
}
55235515

55245516

0 commit comments

Comments
 (0)