aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/proc.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2022-04-12 14:45:23 -0400
committerRobert Haas <rhaas@postgresql.org>2022-04-12 14:45:23 -0400
commit7fc0e7de9fb8306e84d1c15211aba4308f694455 (patch)
treece8d0213123959bce52699e8e8d837d46758a2f6 /src/backend/storage/lmgr/proc.c
parent2c9381840fe2d6d1c3179350493fe5fd3dcf90b5 (diff)
downloadpostgresql-7fc0e7de9fb8306e84d1c15211aba4308f694455.tar.gz
postgresql-7fc0e7de9fb8306e84d1c15211aba4308f694455.zip
Revert the addition of GetMaxBackends() and related stuff.
This reverts commits 0147fc7, 4567596, aa64f23, and 5ecd018. There is no longer agreement that introducing this function was the right way to address the problem. The consensus now seems to favor trying to make a correct value for MaxBackends available to mdules executing their _PG_init() functions. Nathan Bossart Discussion: http://postgr.es/m/20220323045229.i23skfscdbvrsuxa@jrouhaud
Diffstat (limited to 'src/backend/storage/lmgr/proc.c')
-rw-r--r--src/backend/storage/lmgr/proc.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c
index 93d082c45ee..37aaab13381 100644
--- a/src/backend/storage/lmgr/proc.c
+++ b/src/backend/storage/lmgr/proc.c
@@ -103,7 +103,7 @@ ProcGlobalShmemSize(void)
{
Size size = 0;
Size TotalProcs =
- add_size(GetMaxBackends(), add_size(NUM_AUXILIARY_PROCS, max_prepared_xacts));
+ add_size(MaxBackends, add_size(NUM_AUXILIARY_PROCS, max_prepared_xacts));
/* ProcGlobal */
size = add_size(size, sizeof(PROC_HDR));
@@ -127,7 +127,7 @@ ProcGlobalSemas(void)
* We need a sema per backend (including autovacuum), plus one for each
* auxiliary process.
*/
- return GetMaxBackends() + NUM_AUXILIARY_PROCS;
+ return MaxBackends + NUM_AUXILIARY_PROCS;
}
/*
@@ -162,8 +162,7 @@ InitProcGlobal(void)
int i,
j;
bool found;
- int max_backends = GetMaxBackends();
- uint32 TotalProcs = max_backends + NUM_AUXILIARY_PROCS + max_prepared_xacts;
+ uint32 TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS + max_prepared_xacts;
/* Create the ProcGlobal shared structure */
ProcGlobal = (PROC_HDR *)
@@ -196,7 +195,7 @@ InitProcGlobal(void)
MemSet(procs, 0, TotalProcs * sizeof(PGPROC));
ProcGlobal->allProcs = procs;
/* XXX allProcCount isn't really all of them; it excludes prepared xacts */
- ProcGlobal->allProcCount = max_backends + NUM_AUXILIARY_PROCS;
+ ProcGlobal->allProcCount = MaxBackends + NUM_AUXILIARY_PROCS;
/*
* Allocate arrays mirroring PGPROC fields in a dense manner. See
@@ -222,7 +221,7 @@ InitProcGlobal(void)
* dummy PGPROCs don't need these though - they're never associated
* with a real process
*/
- if (i < max_backends + NUM_AUXILIARY_PROCS)
+ if (i < MaxBackends + NUM_AUXILIARY_PROCS)
{
procs[i].sem = PGSemaphoreCreate();
InitSharedLatch(&(procs[i].procLatch));
@@ -259,7 +258,7 @@ InitProcGlobal(void)
ProcGlobal->bgworkerFreeProcs = &procs[i];
procs[i].procgloballist = &ProcGlobal->bgworkerFreeProcs;
}
- else if (i < max_backends)
+ else if (i < MaxBackends)
{
/* PGPROC for walsender, add to walsenderFreeProcs list */
procs[i].links.next = (SHM_QUEUE *) ProcGlobal->walsenderFreeProcs;
@@ -287,8 +286,8 @@ InitProcGlobal(void)
* Save pointers to the blocks of PGPROC structures reserved for auxiliary
* processes and prepared transactions.
*/
- AuxiliaryProcs = &procs[max_backends];
- PreparedXactProcs = &procs[max_backends + NUM_AUXILIARY_PROCS];
+ AuxiliaryProcs = &procs[MaxBackends];
+ PreparedXactProcs = &procs[MaxBackends + NUM_AUXILIARY_PROCS];
/* Create ProcStructLock spinlock, too */
ProcStructLock = (slock_t *) ShmemAlloc(sizeof(slock_t));