mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
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.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: shmem.h,v 1.23 2000/06/28 03:33:27 tgl Exp $
|
||||
* $Id: shmem.h,v 1.24 2000/11/28 23:27:57 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -18,17 +18,23 @@
|
||||
#include "utils/hsearch.h"
|
||||
|
||||
|
||||
/* The shared memory region can start at a different address
|
||||
/*
|
||||
* The shared memory region can start at a different address
|
||||
* in every process. Shared memory "pointers" are actually
|
||||
* offsets relative to the start of the shared memory region(s).
|
||||
*
|
||||
* In current usage, this is not actually a problem, but we keep
|
||||
* the code that used to handle it...
|
||||
*/
|
||||
typedef unsigned long SHMEM_OFFSET;
|
||||
|
||||
#define INVALID_OFFSET (-1)
|
||||
#define BAD_LOCATION (-1)
|
||||
|
||||
/* start of the lowest shared memory region. For now, assume that
|
||||
* there is only one shared memory region
|
||||
/*
|
||||
* Start of the primary shared memory region, in this process' address space.
|
||||
* The macros in this header file can only cope with offsets into this
|
||||
* shared memory region!
|
||||
*/
|
||||
extern SHMEM_OFFSET ShmemBase;
|
||||
|
||||
@@ -39,14 +45,14 @@ extern SHMEM_OFFSET ShmemBase;
|
||||
|
||||
/* coerce a pointer into a shmem offset */
|
||||
#define MAKE_OFFSET(xx_ptr)\
|
||||
(SHMEM_OFFSET) (((unsigned long)(xx_ptr))-ShmemBase)
|
||||
((SHMEM_OFFSET) (((unsigned long)(xx_ptr))-ShmemBase))
|
||||
|
||||
#define SHM_PTR_VALID(xx_ptr)\
|
||||
(((unsigned long)xx_ptr) > ShmemBase)
|
||||
(((unsigned long)(xx_ptr)) > ShmemBase)
|
||||
|
||||
/* cannot have an offset to ShmemFreeStart (offset 0) */
|
||||
#define SHM_OFFSET_VALID(xx_offs)\
|
||||
((xx_offs != 0) && (xx_offs != INVALID_OFFSET))
|
||||
(((xx_offs) != 0) && ((xx_offs) != INVALID_OFFSET))
|
||||
|
||||
|
||||
extern SPINLOCK ShmemLock;
|
||||
@@ -60,11 +66,9 @@ typedef struct SHM_QUEUE
|
||||
} SHM_QUEUE;
|
||||
|
||||
/* shmem.c */
|
||||
extern void ShmemIndexReset(void);
|
||||
extern void ShmemCreate(unsigned int key, unsigned int size);
|
||||
extern int InitShmem(unsigned int key, unsigned int size);
|
||||
extern void InitShmemAllocation(PGShmemHeader *seghdr);
|
||||
extern void *ShmemAlloc(Size size);
|
||||
extern int ShmemIsValid(unsigned long addr);
|
||||
extern bool ShmemIsValid(unsigned long addr);
|
||||
extern HTAB *ShmemInitHash(char *name, long init_size, long max_size,
|
||||
HASHCTL *infoP, int hash_flags);
|
||||
extern bool ShmemPIDLookup(int pid, SHMEM_OFFSET *locationPtr);
|
||||
|
||||
Reference in New Issue
Block a user