diff options
author | Magnus Hagander | 2009-05-04 08:36:40 +0000 |
---|---|---|
committer | Magnus Hagander | 2009-05-04 08:36:40 +0000 |
commit | 4d754acf96ffa01c02dd9882ab0ebfe2fd6ad999 (patch) | |
tree | 394376493fe30512996cf6639127a2803459e678 | |
parent | a8385eae6f9bc16cd4cf3e2f38bb3a0fab74fcf4 (diff) |
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.
-rw-r--r-- | src/backend/port/win32_shmem.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/port/win32_shmem.c b/src/backend/port/win32_shmem.c index a7cc9aab17..80700950aa 100644 --- a/src/backend/port/win32_shmem.c +++ b/src/backend/port/win32_shmem.c @@ -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, |