]> granicus.if.org Git - postgresql/commitdiff
Call SetLastError(0) before calling the file mapping functions
authorMagnus Hagander <magnus@hagander.net>
Mon, 4 May 2009 08:36:44 +0000 (08:36 +0000)
committerMagnus Hagander <magnus@hagander.net>
Mon, 4 May 2009 08:36:44 +0000 (08:36 +0000)
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.

src/backend/port/win32_shmem.c

index 394eb976f04f784674dd5d67f72aab9de7e6abc7..8c61a9aa85e13f63a3fad9bad9529b358fb324f8 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.4.2.2 2008/10/30 17:04:11 mha Exp $
+ *       $PostgreSQL: pgsql/src/backend/port/win32_shmem.c,v 1.4.2.3 2009/05/04 08:36:44 mha Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -131,6 +131,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
 
        UsedShmemSegAddr = NULL;
 
+       /* In case CreateFileMapping() doesn't set the error code to 0 on success */
+       SetLastError(0);
+
        hmap = CreateFileMapping((HANDLE) 0xFFFFFFFF,           /* Use the pagefile */
                                                         NULL,          /* Default security attrs */
                                                         PAGE_READWRITE,        /* Memory is Read/Write */
@@ -160,6 +163,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port)
 
                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);
                if (!hmap)
                        ereport(FATAL,