diff options
author | Heikki Linnakangas | 2024-03-04 08:25:09 +0000 |
---|---|---|
committer | Heikki Linnakangas | 2024-03-04 08:25:09 +0000 |
commit | 067701f57758f9baed5bd9d868539738d77bfa92 (patch) | |
tree | b0f0a10a82b70792862d1f55357055f2211b32db /src/backend | |
parent | a0cd95448067273a5cf92ad578a1e2de3b62aa2f (diff) |
Remove MyAuxProcType, use MyBackendType instead
MyAuxProcType was redundant with MyBackendType.
Reviewed-by: Reid Thompson, Andres Freund
Discussion: https://www.postgresql.org/message-id/f3ecd4cb-85ee-4e54-8278-5fabfb3a4ed0@iki.fi
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/postmaster/auxprocess.c | 58 | ||||
-rw-r--r-- | src/backend/postmaster/postmaster.c | 56 |
2 files changed, 39 insertions, 75 deletions
diff --git a/src/backend/postmaster/auxprocess.c b/src/backend/postmaster/auxprocess.c index 39171fea06b..fc13cd76321 100644 --- a/src/backend/postmaster/auxprocess.c +++ b/src/backend/postmaster/auxprocess.c @@ -38,14 +38,6 @@ static void ShutdownAuxiliaryProcess(int code, Datum arg); -/* ---------------- - * global variables - * ---------------- - */ - -AuxProcType MyAuxProcType = NotAnAuxProcess; /* declared in miscadmin.h */ - - /* * AuxiliaryProcessMain * @@ -55,39 +47,11 @@ AuxProcType MyAuxProcType = NotAnAuxProcess; /* declared in miscadmin.h */ * This code is here just because of historical reasons. */ void -AuxiliaryProcessMain(AuxProcType auxtype) +AuxiliaryProcessMain(BackendType auxtype) { Assert(IsUnderPostmaster); - MyAuxProcType = auxtype; - - switch (MyAuxProcType) - { - case StartupProcess: - MyBackendType = B_STARTUP; - break; - case ArchiverProcess: - MyBackendType = B_ARCHIVER; - break; - case BgWriterProcess: - MyBackendType = B_BG_WRITER; - break; - case CheckpointerProcess: - MyBackendType = B_CHECKPOINTER; - break; - case WalWriterProcess: - MyBackendType = B_WAL_WRITER; - break; - case WalReceiverProcess: - MyBackendType = B_WAL_RECEIVER; - break; - case WalSummarizerProcess: - MyBackendType = B_WAL_SUMMARIZER; - break; - default: - elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType); - MyBackendType = B_INVALID; - } + MyBackendType = auxtype; init_ps_display(NULL); @@ -126,38 +90,38 @@ AuxiliaryProcessMain(AuxProcType auxtype) SetProcessingMode(NormalProcessing); - switch (MyAuxProcType) + switch (MyBackendType) { - case StartupProcess: + case B_STARTUP: StartupProcessMain(); proc_exit(1); - case ArchiverProcess: + case B_ARCHIVER: PgArchiverMain(); proc_exit(1); - case BgWriterProcess: + case B_BG_WRITER: BackgroundWriterMain(); proc_exit(1); - case CheckpointerProcess: + case B_CHECKPOINTER: CheckpointerMain(); proc_exit(1); - case WalWriterProcess: + case B_WAL_WRITER: WalWriterMain(); proc_exit(1); - case WalReceiverProcess: + case B_WAL_RECEIVER: WalReceiverMain(); proc_exit(1); - case WalSummarizerProcess: + case B_WAL_SUMMARIZER: WalSummarizerMain(); proc_exit(1); default: - elog(PANIC, "unrecognized process type: %d", (int) MyAuxProcType); + elog(PANIC, "unrecognized process type: %d", (int) MyBackendType); proc_exit(1); } } diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index da0c627107e..cad5987bcbc 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -442,7 +442,7 @@ static int CountChildren(int target); static bool assign_backendlist_entry(RegisteredBgWorker *rw); static void maybe_start_bgworkers(void); static bool CreateOptsFile(int argc, char *argv[], char *fullprogname); -static pid_t StartChildProcess(AuxProcType type); +static pid_t StartChildProcess(BackendType type); static void StartAutovacuumWorker(void); static void MaybeStartWalReceiver(void); static void MaybeStartWalSummarizer(void); @@ -1452,14 +1452,14 @@ PostmasterMain(int argc, char *argv[]) /* Start bgwriter and checkpointer so they can help with recovery */ if (CheckpointerPID == 0) - CheckpointerPID = StartChildProcess(CheckpointerProcess); + CheckpointerPID = StartChildProcess(B_CHECKPOINTER); if (BgWriterPID == 0) - BgWriterPID = StartChildProcess(BgWriterProcess); + BgWriterPID = StartChildProcess(B_BG_WRITER); /* * We're ready to rock and roll... */ - StartupPID = StartChildProcess(StartupProcess); + StartupPID = StartChildProcess(B_STARTUP); Assert(StartupPID != 0); StartupStatus = STARTUP_RUNNING; pmState = PM_STARTUP; @@ -1793,9 +1793,9 @@ ServerLoop(void) pmState == PM_HOT_STANDBY || pmState == PM_STARTUP) { if (CheckpointerPID == 0) - CheckpointerPID = StartChildProcess(CheckpointerProcess); + CheckpointerPID = StartChildProcess(B_CHECKPOINTER); if (BgWriterPID == 0) - BgWriterPID = StartChildProcess(BgWriterProcess); + BgWriterPID = StartChildProcess(B_BG_WRITER); } /* @@ -1804,7 +1804,7 @@ ServerLoop(void) * be writing any new WAL). */ if (WalWriterPID == 0 && pmState == PM_RUN) - WalWriterPID = StartChildProcess(WalWriterProcess); + WalWriterPID = StartChildProcess(B_WAL_WRITER); /* * If we have lost the autovacuum launcher, try to start a new one. We @@ -1823,7 +1823,7 @@ ServerLoop(void) /* If we have lost the archiver, try to start a new one. */ if (PgArchPID == 0 && PgArchStartupAllowed()) - PgArchPID = StartChildProcess(ArchiverProcess); + PgArchPID = StartChildProcess(B_ARCHIVER); /* If we need to start a slot sync worker, try to do that now */ MaybeStartSlotSyncWorker(); @@ -3003,11 +3003,11 @@ process_pm_child_exit(void) * if this fails, we'll just try again later. */ if (CheckpointerPID == 0) - CheckpointerPID = StartChildProcess(CheckpointerProcess); + CheckpointerPID = StartChildProcess(B_CHECKPOINTER); if (BgWriterPID == 0) - BgWriterPID = StartChildProcess(BgWriterProcess); + BgWriterPID = StartChildProcess(B_BG_WRITER); if (WalWriterPID == 0) - WalWriterPID = StartChildProcess(WalWriterProcess); + WalWriterPID = StartChildProcess(B_WAL_WRITER); MaybeStartWalSummarizer(); /* @@ -3017,7 +3017,7 @@ process_pm_child_exit(void) if (!IsBinaryUpgrade && AutoVacuumingActive() && AutoVacPID == 0) AutoVacPID = StartAutoVacLauncher(); if (PgArchStartupAllowed() && PgArchPID == 0) - PgArchPID = StartChildProcess(ArchiverProcess); + PgArchPID = StartChildProcess(B_ARCHIVER); MaybeStartSlotSyncWorker(); /* workers may be scheduled to start now */ @@ -3173,7 +3173,7 @@ process_pm_child_exit(void) HandleChildCrash(pid, exitstatus, _("archiver process")); if (PgArchStartupAllowed()) - PgArchPID = StartChildProcess(ArchiverProcess); + PgArchPID = StartChildProcess(B_ARCHIVER); continue; } @@ -3777,7 +3777,7 @@ PostmasterStateMachine(void) Assert(Shutdown > NoShutdown); /* Start the checkpointer if not running */ if (CheckpointerPID == 0) - CheckpointerPID = StartChildProcess(CheckpointerProcess); + CheckpointerPID = StartChildProcess(B_CHECKPOINTER); /* And tell it to shut down */ if (CheckpointerPID != 0) { @@ -3932,7 +3932,7 @@ PostmasterStateMachine(void) /* re-create shared memory and semaphores */ CreateSharedMemoryAndSemaphores(); - StartupPID = StartChildProcess(StartupProcess); + StartupPID = StartChildProcess(B_STARTUP); Assert(StartupPID != 0); StartupStatus = STARTUP_RUNNING; pmState = PM_STARTUP; @@ -4967,7 +4967,7 @@ SubPostmasterMain(int argc, char *argv[]) } if (strcmp(argv[1], "--forkaux") == 0) { - AuxProcType auxtype; + BackendType auxtype; Assert(argc == 4); @@ -5087,7 +5087,7 @@ process_pm_pmsignal(void) */ Assert(PgArchPID == 0); if (XLogArchivingAlways()) - PgArchPID = StartChildProcess(ArchiverProcess); + PgArchPID = StartChildProcess(B_ARCHIVER); /* * If we aren't planning to enter hot standby mode later, treat @@ -5313,7 +5313,7 @@ CountChildren(int target) * to start subprocess. */ static pid_t -StartChildProcess(AuxProcType type) +StartChildProcess(BackendType type) { pid_t pid; @@ -5365,31 +5365,31 @@ StartChildProcess(AuxProcType type) errno = save_errno; switch (type) { - case StartupProcess: + case B_STARTUP: ereport(LOG, (errmsg("could not fork startup process: %m"))); break; - case ArchiverProcess: + case B_ARCHIVER: ereport(LOG, (errmsg("could not fork archiver process: %m"))); break; - case BgWriterProcess: + case B_BG_WRITER: ereport(LOG, (errmsg("could not fork background writer process: %m"))); break; - case CheckpointerProcess: + case B_CHECKPOINTER: ereport(LOG, (errmsg("could not fork checkpointer process: %m"))); break; - case WalWriterProcess: + case B_WAL_WRITER: ereport(LOG, (errmsg("could not fork WAL writer process: %m"))); break; - case WalReceiverProcess: + case B_WAL_RECEIVER: ereport(LOG, (errmsg("could not fork WAL receiver process: %m"))); break; - case WalSummarizerProcess: + case B_WAL_SUMMARIZER: ereport(LOG, (errmsg("could not fork WAL summarizer process: %m"))); break; @@ -5403,7 +5403,7 @@ StartChildProcess(AuxProcType type) * fork failure is fatal during startup, but there's no need to choke * immediately if starting other child types fails. */ - if (type == StartupProcess) + if (type == B_STARTUP) ExitPostmaster(1); return 0; } @@ -5522,7 +5522,7 @@ MaybeStartWalReceiver(void) pmState == PM_HOT_STANDBY) && Shutdown <= SmartShutdown) { - WalReceiverPID = StartChildProcess(WalReceiverProcess); + WalReceiverPID = StartChildProcess(B_WAL_RECEIVER); if (WalReceiverPID != 0) WalReceiverRequested = false; /* else leave the flag set, so we'll try again later */ @@ -5539,7 +5539,7 @@ MaybeStartWalSummarizer(void) if (summarize_wal && WalSummarizerPID == 0 && (pmState == PM_RUN || pmState == PM_HOT_STANDBY) && Shutdown <= SmartShutdown) - WalSummarizerPID = StartChildProcess(WalSummarizerProcess); + WalSummarizerPID = StartChildProcess(B_WAL_SUMMARIZER); } |