1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Pass shared memory id and socket descriptor number on command line for

fork/exec.
This commit is contained in:
Bruce Momjian
2003-05-06 23:34:56 +00:00
parent e8f4f2f92d
commit d9fd7d12f6
6 changed files with 83 additions and 21 deletions

View File

@@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.7 2003/04/24 21:24:36 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.8 2003/05/06 23:34:55 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,13 +34,15 @@
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
typedef uint32 IpcMemoryKey; /* shared memory key passed to shmget(2) */
typedef int IpcMemoryId; /* shared memory ID returned by shmget(2) */
#define IPCProtection (0600) /* access/modify by user only */
#ifdef EXEC_BACKEND
IpcMemoryKey UsedShmemSegID = 0;
#endif
static void *InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size);
static void IpcMemoryDetach(int status, Datum shmaddr);
static void IpcMemoryDelete(int status, Datum shmId);
@@ -300,10 +302,14 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
/* Room for a header? */
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
/* Loop till we find a free IPC key */
NextShmemSegID = port * 1000;
#ifdef EXEC_BACKEND
if (UsedShmemSegID != 0)
NextShmemSegID = UsedShmemSegID;
else
#endif
NextShmemSegID = port * 1000 + 1;
for (NextShmemSegID++;; NextShmemSegID++)
for (;;NextShmemSegID++)
{
IpcMemoryId shmid;
@@ -395,5 +401,10 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
hdr->totalsize = size;
hdr->freeoffset = MAXALIGN(sizeof(PGShmemHeader));
#ifdef EXEC_BACKEND
if (!makePrivate && UsedShmemSegID == 0)
UsedShmemSegID = NextShmemSegID;
#endif
return hdr;
}