summaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/proc.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-04 10:25:12 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-03-04 10:25:12 +0200
commit393b5599e5177e456cdce500039813629d370b38 (patch)
treebafd118d5dd94f63bcc711457a6d9c9248064051 /src/backend/storage/lmgr/proc.c
parent067701f57758f9baed5bd9d868539738d77bfa92 (diff)
Use MyBackendType in more places to check what process this is
Remove IsBackgroundWorker, IsAutoVacuumLauncherProcess(), IsAutoVacuumWorkerProcess(), and IsLogicalSlotSyncWorker() in favor of new Am*Process() macros that use MyBackendType. For consistency with the existing Am*Process() macros. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/f3ecd4cb-85ee-4e54-8278-5fabfb3a4ed0@iki.fi
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r--src/backend/storage/lmgr/proc.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 1867fff9cd8..1949d149656 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -42,7 +42,6 @@
#include "replication/slot.h"
#include "replication/slotsync.h"
#include "replication/syncrep.h"
-#include "replication/walsender.h"
#include "storage/condition_variable.h"
#include "storage/ipc.h"
#include "storage/lmgr.h"
@@ -310,11 +309,11 @@ InitProcess(void)
elog(ERROR, "you already exist");
/* Decide which list should supply our PGPROC. */
- if (IsAnyAutoVacuumProcess())
+ if (AmAutoVacuumLauncherProcess() || AmAutoVacuumWorkerProcess())
procgloballist = &ProcGlobal->autovacFreeProcs;
- else if (IsBackgroundWorker)
+ else if (AmBackgroundWorkerProcess())
procgloballist = &ProcGlobal->bgworkerFreeProcs;
- else if (am_walsender)
+ else if (AmWalSenderProcess())
procgloballist = &ProcGlobal->walsenderFreeProcs;
else
procgloballist = &ProcGlobal->freeProcs;
@@ -344,7 +343,7 @@ InitProcess(void)
* in the autovacuum case?
*/
SpinLockRelease(ProcStructLock);
- if (am_walsender)
+ if (AmWalSenderProcess())
ereport(FATAL,
(errcode(ERRCODE_TOO_MANY_CONNECTIONS),
errmsg("number of requested standby connections exceeds max_wal_senders (currently %d)",
@@ -370,8 +369,8 @@ InitProcess(void)
* Slot sync worker also does not participate in it, see comments atop
* 'struct bkend' in postmaster.c.
*/
- if (IsUnderPostmaster && !IsAutoVacuumLauncherProcess() &&
- !IsLogicalSlotSyncWorker())
+ if (IsUnderPostmaster && !AmAutoVacuumLauncherProcess() &&
+ !AmLogicalSlotSyncWorkerProcess())
MarkPostmasterChildActive();
/*
@@ -391,11 +390,11 @@ InitProcess(void)
MyProc->databaseId = InvalidOid;
MyProc->roleId = InvalidOid;
MyProc->tempNamespaceId = InvalidOid;
- MyProc->isBackgroundWorker = IsBackgroundWorker;
+ MyProc->isBackgroundWorker = AmBackgroundWorkerProcess();
MyProc->delayChkptFlags = 0;
MyProc->statusFlags = 0;
/* NB -- autovac launcher intentionally does not set IS_AUTOVACUUM */
- if (IsAutoVacuumWorkerProcess())
+ if (AmAutoVacuumWorkerProcess())
MyProc->statusFlags |= PROC_IS_AUTOVACUUM;
MyProc->lwWaiting = LW_WS_NOT_WAITING;
MyProc->lwWaitMode = 0;
@@ -587,7 +586,7 @@ InitAuxiliaryProcess(void)
MyProc->databaseId = InvalidOid;
MyProc->roleId = InvalidOid;
MyProc->tempNamespaceId = InvalidOid;
- MyProc->isBackgroundWorker = IsBackgroundWorker;
+ MyProc->isBackgroundWorker = AmBackgroundWorkerProcess();
MyProc->delayChkptFlags = 0;
MyProc->statusFlags = 0;
MyProc->lwWaiting = LW_WS_NOT_WAITING;
@@ -951,8 +950,8 @@ ProcKill(int code, Datum arg)
* Slot sync worker is also not a postmaster child, so skip this shared
* memory related processing here.
*/
- if (IsUnderPostmaster && !IsAutoVacuumLauncherProcess() &&
- !IsLogicalSlotSyncWorker())
+ if (IsUnderPostmaster && !AmAutoVacuumLauncherProcess() &&
+ !AmLogicalSlotSyncWorkerProcess())
MarkPostmasterChildInactive();
/* wake autovac launcher if needed -- see comments in FreeWorkerInfo */