1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

Native shared memory implementation for win32.

Uses same underlying tech as before, but not the sysv emulation layer.
This commit is contained in:
Magnus Hagander
2007-03-21 14:39:23 +00:00
parent 3b765dba78
commit 18d82d03b5
7 changed files with 310 additions and 151 deletions

View File

@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.49 2007/02/06 16:20:23 tgl Exp $
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.50 2007/03/21 14:39:23 mha Exp $
*
*-------------------------------------------------------------------------
*/
@ -195,11 +195,8 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
{
IpcMemoryId shmId = (IpcMemoryId) id2;
struct shmid_ds shmStat;
#ifndef WIN32
struct stat statbuf;
PGShmemHeader *hdr;
#endif
/*
* We detect whether a shared memory segment is in use by seeing whether
@ -238,11 +235,8 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
/*
* Try to attach to the segment and see if it matches our data directory.
* This avoids shmid-conflict problems on machines that are running
* several postmasters under the same userid. On Windows, which doesn't
* have useful inode numbers, we can't do this so we punt and assume there
* is a conflict.
* several postmasters under the same userid.
*/
#ifndef WIN32
if (stat(DataDir, &statbuf) < 0)
return true; /* if can't stat, be conservative */
@ -265,7 +259,6 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
/* Trouble --- looks a lot like there's still live backends */
shmdt((void *) hdr);
#endif
return true;
}
@ -296,10 +289,7 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
void *memAddress;
PGShmemHeader *hdr;
IpcMemoryId shmid;
#ifndef WIN32
struct stat statbuf;
#endif
/* Room for a header? */
Assert(size > MAXALIGN(sizeof(PGShmemHeader)));
@ -372,7 +362,6 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
hdr->creatorPID = getpid();
hdr->magic = PGShmemMagic;
#ifndef WIN32
/* Fill in the data directory ID info, too */
if (stat(DataDir, &statbuf) < 0)
ereport(FATAL,
@ -381,7 +370,6 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
DataDir)));
hdr->device = statbuf.st_dev;
hdr->inode = statbuf.st_ino;
#endif
/*
* Initialize space allocation status for segment.