diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-05-28 05:13:32 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-05-28 05:13:32 +0000 |
commit | 1a321f26d88e5c64bccba9d36920aede1e201729 (patch) | |
tree | 43940a3ed5cc754bff68748502550731b0ad19a0 /src/backend/storage/lmgr/lock.c | |
parent | 37da0ba0e0f2d92857dc62789820d21e177dc00f (diff) | |
download | postgresql-1a321f26d88e5c64bccba9d36920aede1e201729.tar.gz postgresql-1a321f26d88e5c64bccba9d36920aede1e201729.zip |
Code review for EXEC_BACKEND changes. Reduce the number of #ifdefs by
about a third, make it work on non-Windows platforms again. (But perhaps
I broke the WIN32 code, since I have no way to test that.) Fold all the
paths that fork postmaster child processes to go through the single
routine SubPostmasterMain, which takes care of resurrecting the state that
would normally be inherited from the postmaster (including GUC variables).
Clean up some places where there's no particularly good reason for the
EXEC and non-EXEC cases to work differently. Take care of one or two
FIXMEs that remained in the code.
Diffstat (limited to 'src/backend/storage/lmgr/lock.c')
-rw-r--r-- | src/backend/storage/lmgr/lock.c | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 8cb25b4ccdd..88179a0731a 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.131 2003/12/20 17:31:21 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/lmgr/lock.c,v 1.132 2004/05/28 05:13:05 tgl Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -155,7 +155,9 @@ PROCLOCK_PRINT(const char *where, const PROCLOCK *proclockP) static LockMethod LockMethods[MAX_LOCK_METHODS]; static HTAB* LockMethodLockHash[MAX_LOCK_METHODS]; static HTAB* LockMethodProcLockHash[MAX_LOCK_METHODS]; -static int NumLockMethods; + +/* exported so lmgr.c can initialize it */ +int NumLockMethods; /* @@ -190,15 +192,15 @@ GetLocksMethodTable(LOCK *lock) */ static void LockMethodInit(LockMethod lockMethodTable, - LOCKMASK *conflictsP, + const LOCKMASK *conflictsP, int numModes) { int i; lockMethodTable->numLockModes = numModes; /* copies useless zero element as well as the N lockmodes */ - for (i = 0; i <= numModes; i++, conflictsP++) - lockMethodTable->conflictTab[i] = *conflictsP; + for (i = 0; i <= numModes; i++) + lockMethodTable->conflictTab[i] = conflictsP[i]; } /* @@ -211,8 +213,8 @@ LockMethodInit(LockMethod lockMethodTable, * TopMemoryContext. */ LOCKMETHODID -LockMethodTableInit(char *tabName, - LOCKMASK *conflictsP, +LockMethodTableInit(const char *tabName, + const LOCKMASK *conflictsP, int numModes, int maxBackends) { @@ -245,17 +247,6 @@ LockMethodTableInit(char *tabName, elog(FATAL, "could not initialize lock table \"%s\"", tabName); /* - * Lock the LWLock for the table (probably not necessary here) - */ -#ifndef EXEC_BACKEND - LWLockAcquire(LockMgrLock, LW_EXCLUSIVE); -#endif - /* - * no zero-th table - */ - NumLockMethods = 1; - - /* * we're first - initialize */ if (!found) @@ -263,6 +254,7 @@ LockMethodTableInit(char *tabName, MemSet(newLockMethod, 0, sizeof(LockMethodData)); newLockMethod->masterLock = LockMgrLock; newLockMethod->lockmethodid = NumLockMethods; + LockMethodInit(newLockMethod, conflictsP, numModes); } /* @@ -311,12 +303,6 @@ LockMethodTableInit(char *tabName, if (!LockMethodProcLockHash[NumLockMethods-1]) elog(FATAL, "could not initialize lock table \"%s\"", tabName); - /* init data structures */ - LockMethodInit(newLockMethod, conflictsP, numModes); - -#ifndef EXEC_BACKEND - LWLockRelease(LockMgrLock); -#endif pfree(shmemName); return newLockMethod->lockmethodid; |