Commit ca6c0ac4 authored by Magnus Hagander's avatar Magnus Hagander

Call SetLastError(0) before calling the file mapping functions

to make sure that the error code is reset, as a precaution in
case the API doesn't properly reset it on success. This could
be necessary, since we check the error value even if the function
doesn't fail for specific success cases.
parent ffbd17e7
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.7 2009/01/01 17:23:46 momjian Exp $ * $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.8 2009/05/04 08:36:40 mha Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -131,6 +131,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) ...@@ -131,6 +131,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
UsedShmemSegAddr = NULL; UsedShmemSegAddr = NULL;
/* In case CreateFileMapping() doesn't set the error code to 0 on success */
SetLastError(0);
hmap = CreateFileMapping((HANDLE) 0xFFFFFFFF, /* Use the pagefile */ hmap = CreateFileMapping((HANDLE) 0xFFFFFFFF, /* Use the pagefile */
NULL, /* Default security attrs */ NULL, /* Default security attrs */
PAGE_READWRITE, /* Memory is Read/Write */ PAGE_READWRITE, /* Memory is Read/Write */
...@@ -160,6 +163,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port) ...@@ -160,6 +163,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
Sleep(1000); Sleep(1000);
/* In case CreateFileMapping() doesn't set the error code to 0 on success */
SetLastError(0);
hmap = CreateFileMapping((HANDLE) 0xFFFFFFFF, NULL, PAGE_READWRITE, 0L, (DWORD) size, szShareMem); hmap = CreateFileMapping((HANDLE) 0xFFFFFFFF, NULL, PAGE_READWRITE, 0L, (DWORD) size, szShareMem);
if (!hmap) if (!hmap)
ereport(FATAL, ereport(FATAL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment