aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/buf_init.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-11-28 23:27:57 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-11-28 23:27:57 +0000
commitc715fdea267843fd7fae4253aee0ae91e941393c (patch)
treeb19e41edd57afe461ebc3dae271c8a5d17eba710 /src/backend/storage/buffer/buf_init.c
parent914822713c9a8ce452860fb895ef79ecfd583746 (diff)
downloadpostgresql-c715fdea267843fd7fae4253aee0ae91e941393c.tar.gz
postgresql-c715fdea267843fd7fae4253aee0ae91e941393c.zip
Significant cleanups in SysV IPC handling (shared mem and semaphores).
IPC key assignment will now work correctly even when multiple postmasters are using same logical port number (which is possible given -k switch). There is only one shared-mem segment per postmaster now, not 3. Rip out broken code for non-TAS case in bufmgr and xlog, substitute a complete S_LOCK emulation using semaphores in spin.c. TAS and non-TAS logic is now exactly the same. When deadlock is detected, "Deadlock detected" is now the elog(ERROR) message, rather than a NOTICE that comes out before an unhelpful ERROR.
Diffstat (limited to 'src/backend/storage/buffer/buf_init.c')
-rw-r--r--src/backend/storage/buffer/buf_init.c43
1 files changed, 3 insertions, 40 deletions
diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c
index 3c40009422d..0fda21972f6 100644
--- a/src/backend/storage/buffer/buf_init.c
+++ b/src/backend/storage/buffer/buf_init.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.37 2000/10/23 04:10:06 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.38 2000/11/28 23:27:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -56,13 +56,6 @@ int Num_Descriptors;
BufferDesc *BufferDescriptors;
BufferBlock BufferBlocks;
-#ifndef HAS_TEST_AND_SET
-long *NWaitIOBackendP;
-
-#endif
-
-extern IpcSemaphoreId WaitIOSemId;
-
long *PrivateRefCount; /* also used in freelist.c */
bits8 *BufferLocks; /* flag bits showing locks I have set */
BufferTag *BufferTagLastDirtied; /* tag buffer had when last
@@ -139,7 +132,7 @@ long int LocalBufferFlushCount;
* amount of available memory.
*/
void
-InitBufferPool(IPCKey key)
+InitBufferPool(void)
{
bool foundBufs,
foundDescs;
@@ -170,18 +163,6 @@ InitBufferPool(IPCKey key)
ShmemInitStruct("Buffer Blocks",
NBuffers * BLCKSZ, &foundBufs);
-#ifndef HAS_TEST_AND_SET
- {
- bool foundNWaitIO;
-
- NWaitIOBackendP = (long *) ShmemInitStruct("#Backends Waiting IO",
- sizeof(long),
- &foundNWaitIO);
- if (!foundNWaitIO)
- *NWaitIOBackendP = 0;
- }
-#endif
-
if (foundDescs || foundBufs)
{
@@ -214,10 +195,8 @@ InitBufferPool(IPCKey key)
buf->flags = (BM_DELETED | BM_FREE | BM_VALID);
buf->refcount = 0;
buf->buf_id = i;
-#ifdef HAS_TEST_AND_SET
S_INIT_LOCK(&(buf->io_in_progress_lock));
S_INIT_LOCK(&(buf->cntx_lock));
-#endif
}
/* close the circular queue */
@@ -231,22 +210,6 @@ InitBufferPool(IPCKey key)
SpinRelease(BufMgrLock);
-#ifndef HAS_TEST_AND_SET
- {
- extern IpcSemaphoreId WaitIOSemId;
- extern IpcSemaphoreId WaitCLSemId;
-
- WaitIOSemId = IpcSemaphoreCreate(IPCKeyGetWaitIOSemaphoreKey(key),
- 1, IPCProtection, 0, 1);
- if (WaitIOSemId < 0)
- elog(FATAL, "InitBufferPool: IpcSemaphoreCreate(WaitIOSemId) failed");
- WaitCLSemId = IpcSemaphoreCreate(IPCKeyGetWaitCLSemaphoreKey(key),
- 1, IPCProtection,
- IpcSemaphoreDefaultStartValue, 1);
- if (WaitCLSemId < 0)
- elog(FATAL, "InitBufferPool: IpcSemaphoreCreate(WaitCLSemId) failed");
- }
-#endif
PrivateRefCount = (long *) calloc(NBuffers, sizeof(long));
BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8));
BufferTagLastDirtied = (BufferTag *) calloc(NBuffers, sizeof(BufferTag));
@@ -262,7 +225,7 @@ InitBufferPool(IPCKey key)
* ----------------------------------------------------
*/
int
-BufferShmemSize()
+BufferShmemSize(void)
{
int size = 0;