diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-11-21 06:36:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-11-21 06:36:08 +0000 |
commit | 8362be35e82574801113a7fe4dfdc3037010fc04 (patch) | |
tree | b5603e45b2956d5dc8b52f9adf2c02f9d42494ed /src/backend/storage/ipc | |
parent | 02d83d7565bfa306f876c3fecc89a159e28e0e3b (diff) | |
download | postgresql-8362be35e82574801113a7fe4dfdc3037010fc04.tar.gz postgresql-8362be35e82574801113a7fe4dfdc3037010fc04.zip |
Code review for superuser_reserved_connections patch. Don't try to do
database access outside a transaction; revert bogus performance improvement
in SIBackendInit(); improve comments; add documentation (this part courtesy
Neil Conway).
Diffstat (limited to 'src/backend/storage/ipc')
-rw-r--r-- | src/backend/storage/ipc/sinval.c | 13 | ||||
-rw-r--r-- | src/backend/storage/ipc/sinvaladt.c | 24 |
2 files changed, 19 insertions, 18 deletions
diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index 87f7a292452..239c3bc8d30 100644 --- a/src/backend/storage/ipc/sinval.c +++ b/src/backend/storage/ipc/sinval.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.52 2002/09/04 20:31:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.53 2002/11/21 06:36:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -542,12 +542,11 @@ BackendIdGetProc(BackendId procId) /* * CountEmptyBackendSlots - count empty slots in backend process table * - * Doesn't count since the procState array could be large and we've already - * allowed for that by running a freeBackends counter in the SI segment. - * Unlike CountActiveBackends() we do not need to interrogate the - * backends to determine the free slot count. - * Goes for a lock despite being a trival look up in case other backends - * are busy starting or exiting since there is scope for confusion. + * We don't actually need to count, since sinvaladt.c maintains a + * freeBackends counter in the SI segment. + * + * Acquiring the lock here is almost certainly overkill, but just in + * case fetching an int is not atomic on your machine ... */ int CountEmptyBackendSlots(void) diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c index b4ab1689f94..6850fa8cf52 100644 --- a/src/backend/storage/ipc/sinvaladt.c +++ b/src/backend/storage/ipc/sinvaladt.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.48 2002/08/29 21:02:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.49 2002/11/21 06:36:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -92,13 +92,6 @@ SIBackendInit(SISeg *segP) int index; ProcState *stateP = NULL; - if (segP->freeBackends == 0) - { - /* out of procState slots */ - MyBackendId = InvalidBackendId; - return 0; - } - /* Look for a free entry in the procState array */ for (index = 0; index < segP->lastBackend; index++) { @@ -111,9 +104,18 @@ SIBackendInit(SISeg *segP) if (stateP == NULL) { - stateP = &segP->procState[segP->lastBackend]; - Assert(stateP->nextMsgNum < 0); - segP->lastBackend++; + if (segP->lastBackend < segP->maxBackends) + { + stateP = &segP->procState[segP->lastBackend]; + Assert(stateP->nextMsgNum < 0); + segP->lastBackend++; + } + else + { + /* out of procState slots */ + MyBackendId = InvalidBackendId; + return 0; + } } MyBackendId = (stateP - &segP->procState[0]) + 1; |