Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1a81daa

Browse files
committed
Try to fix spurious DSM failures on Windows.
Apparently, Windows can sometimes return an error code even when the operation actually worked just fine. Rearrange the order of checks according to what appear to be the best practices in this area. Amit Kapila
1 parent ed4a262 commit 1a81daa

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/backend/storage/ipc/dsm_impl.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,15 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
693693
size_high, /* Upper 32 bits of size */
694694
size_low, /* Lower 32 bits of size */
695695
name);
696+
if (!hmap)
697+
{
698+
_dosmaperr(GetLastError());
699+
ereport(elevel,
700+
(errcode_for_dynamic_shared_memory(),
701+
errmsg("could not create shared memory segment \"%s\": %m",
702+
name)));
703+
return false;
704+
}
696705
_dosmaperr(GetLastError());
697706
if (errno == EEXIST)
698707
{
@@ -711,16 +720,15 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
711720
hmap = OpenFileMapping(FILE_MAP_WRITE | FILE_MAP_READ,
712721
FALSE, /* do not inherit the name */
713722
name); /* name of mapping object */
714-
_dosmaperr(GetLastError());
715-
}
716-
717-
if (!hmap)
718-
{
719-
ereport(elevel,
720-
(errcode_for_dynamic_shared_memory(),
721-
errmsg("could not open shared memory segment \"%s\": %m",
722-
name)));
723-
return false;
723+
if (!hmap)
724+
{
725+
_dosmaperr(GetLastError());
726+
ereport(elevel,
727+
(errcode_for_dynamic_shared_memory(),
728+
errmsg("could not open shared memory segment \"%s\": %m",
729+
name)));
730+
return false;
731+
}
724732
}
725733

726734
/* Map it. */

0 commit comments

Comments
 (0)