summaryrefslogtreecommitdiff
path: root/src/include/storage/ipc.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-05-05 00:03:29 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-05-05 00:03:29 +0000
commit72a3902a664c7fbceb2034e28e444b28f96fa717 (patch)
treeff42e4494af6ea1c1cdf524f3feb5fc670217f0c /src/include/storage/ipc.h
parent91fc10fdacfcbadc123fd9d8ee16a4568f8c636b (diff)
Create an internal semaphore API that is not tied to SysV semaphores.
As proof of concept, provide an alternate implementation based on POSIX semaphores. Also push the SysV shared-memory implementation into a separate file so that it can be replaced conveniently.
Diffstat (limited to 'src/include/storage/ipc.h')
-rw-r--r--src/include/storage/ipc.h71
1 files changed, 7 insertions, 64 deletions
diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h
index 6a96ea2d125..5ebee36b9f7 100644
--- a/src/include/storage/ipc.h
+++ b/src/include/storage/ipc.h
@@ -3,63 +3,21 @@
* ipc.h
* POSTGRES inter-process communication definitions.
*
+ * This file is misnamed, as it no longer has much of anything directly
+ * to do with IPC. The functionality here is concerned with managing
+ * exit-time cleanup for either a postmaster or a backend.
+ *
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: ipc.h,v 1.54 2001/11/05 17:46:35 momjian Exp $
+ * $Id: ipc.h,v 1.55 2002/05/05 00:03:29 tgl Exp $
*
- * Some files that would normally need to include only sys/ipc.h must
- * instead include this file because on Ultrix, sys/ipc.h is not designed
- * to be included multiple times. This file (by virtue of the ifndef IPC_H)
- * is.
*-------------------------------------------------------------------------
*/
#ifndef IPC_H
#define IPC_H
-#include <sys/types.h>
-#ifdef HAVE_SYS_IPC_H
-#include <sys/ipc.h>
-#endif /* HAVE_SYS_IPC_H */
-
-#ifndef HAVE_UNION_SEMUN
-union semun
-{
- int val;
- struct semid_ds *buf;
- unsigned short *array;
-};
-#endif
-
-
-/* generic IPC definitions */
-
-#define IPCProtection (0600) /* access/modify by user only */
-
-/* semaphore definitions */
-
-typedef uint32 IpcSemaphoreKey; /* semaphore key passed to semget(2) */
-typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */
-
-#define IPC_NMAXSEM 32 /* maximum number of semaphores per semID */
-
-#define PGSemaMagic 537 /* must be less than SEMVMX */
-
-/* shared memory definitions */
-
-typedef uint32 IpcMemoryKey; /* shared memory key passed to shmget(2) */
-typedef int IpcMemoryId; /* shared memory ID returned by shmget(2) */
-
-typedef struct PGShmemHeader /* standard header for all Postgres shmem */
-{
- int32 magic; /* magic # to identify Postgres segments */
-#define PGShmemMagic 679834892
- pid_t creatorPID; /* PID of creating process */
- uint32 totalsize; /* total size of segment */
- uint32 freeoffset; /* offset to first free space */
-} PGShmemHeader;
-
/* ipc.c */
extern bool proc_exit_inprogress;
@@ -70,24 +28,9 @@ extern void on_proc_exit(void (*function) (), Datum arg);
extern void on_shmem_exit(void (*function) (), Datum arg);
extern void on_exit_reset(void);
-extern void IpcInitKeyAssignment(int port);
-
-extern IpcSemaphoreId IpcSemaphoreCreate(int numSems, int permission,
- int semStartValue,
- bool removeOnExit);
-extern void IpcSemaphoreKill(IpcSemaphoreId semId);
-extern void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, bool interruptOK);
-extern void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem);
-extern bool IpcSemaphoreTryLock(IpcSemaphoreId semId, int sem);
-extern int IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem);
-
-extern PGShmemHeader *IpcMemoryCreate(uint32 size, bool makePrivate,
- int permission);
-
-extern bool SharedMemoryIsInUse(IpcMemoryKey shmKey, IpcMemoryId shmId);
-
/* ipci.c */
extern void CreateSharedMemoryAndSemaphores(bool makePrivate,
- int maxBackends);
+ int maxBackends,
+ int port);
#endif /* IPC_H */