summaryrefslogtreecommitdiff
path: root/src/backend/port/win32_shmem.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-04-08 11:39:55 -0400
committerRobert Haas <rhaas@postgresql.org>2014-04-08 11:39:55 -0400
commit11a65eed1637a05b03e174700799b024e104bfb4 (patch)
treec6634e65fcfc2f3eb7e86f09d18ac9562a46cb24 /src/backend/port/win32_shmem.c
parent0886fc6a5c75b294544263ea979b9cf6195407d9 (diff)
Get rid of the dynamic shared memory state file.
Instead of storing the ID of the dynamic shared memory control segment in a file within the data directory, store it in the main control segment. This avoids a number of nasty corner cases, most seriously that doing an online backup and then using it on the same machine (e.g. to fire up a standby) would result in the standby clobbering all of the master's dynamic shared memory segments. Per complaints from Heikki Linnakangas, Fujii Masao, and Tom Lane.
Diffstat (limited to 'src/backend/port/win32_shmem.c')
-rw-r--r--src/backend/port/win32_shmem.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/port/win32_shmem.c b/src/backend/port/win32_shmem.c
index dca371cce62..3a0ded48650 100644
--- a/src/backend/port/win32_shmem.c
+++ b/src/backend/port/win32_shmem.c
@@ -117,7 +117,8 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
*
*/
PGShmemHeader *
-PGSharedMemoryCreate(Size size, bool makePrivate, int port)
+PGSharedMemoryCreate(Size size, bool makePrivate, int port,
+ PGShmemHeader **shim)
{
void *memAddress;
PGShmemHeader *hdr;
@@ -245,12 +246,14 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
*/
hdr->totalsize = size;
hdr->freeoffset = MAXALIGN(sizeof(PGShmemHeader));
+ hdr->dsm_control = 0;
/* Save info for possible future use */
UsedShmemSegAddr = memAddress;
UsedShmemSegSize = size;
UsedShmemSegID = hmap2;
+ *shim = NULL;
return hdr;
}
@@ -289,6 +292,7 @@ PGSharedMemoryReAttach(void)
hdr, origUsedShmemSegAddr);
if (hdr->magic != PGShmemMagic)
elog(FATAL, "reattaching to shared memory returned non-PostgreSQL memory");
+ dsm_set_control_handle(hdr->dsm_control);
UsedShmemSegAddr = hdr; /* probably redundant */
}