Commit 4acf99b2 authored by Magnus Hagander's avatar Magnus Hagander

Send paramHandle to subprocesses as 64-bit on Win64

The handle to the shared memory segment containing startup
parameters was sent as 32-bit even on 64-bit systems. Since
HANDLEs appear to be allocated sequentially this shouldn't
be a problem until we reach 2^32 open handles in the postmaster,
but a 64-bit value should be sent across as 64-bit, and not
zero out the top 32 bits.

Noted by Tom Lane.
parent 2edc5cd4
...@@ -3755,7 +3755,11 @@ internal_forkexec(int argc, char *argv[], Port *port) ...@@ -3755,7 +3755,11 @@ internal_forkexec(int argc, char *argv[], Port *port)
} }
/* Insert temp file name after --fork argument */ /* Insert temp file name after --fork argument */
#ifdef _WIN64
sprintf(paramHandleStr, "%llu", (LONG_PTR) paramHandle);
#else
sprintf(paramHandleStr, "%lu", (DWORD) paramHandle); sprintf(paramHandleStr, "%lu", (DWORD) paramHandle);
#endif
argv[2] = paramHandleStr; argv[2] = paramHandleStr;
/* Format the cmd line */ /* Format the cmd line */
...@@ -4825,7 +4829,11 @@ read_backend_variables(char *id, Port *port) ...@@ -4825,7 +4829,11 @@ read_backend_variables(char *id, Port *port)
HANDLE paramHandle; HANDLE paramHandle;
BackendParameters *paramp; BackendParameters *paramp;
#ifdef _WIN64
paramHandle = (HANDLE) _atoi64(id);
#else
paramHandle = (HANDLE) atol(id); paramHandle = (HANDLE) atol(id);
#endif
paramp = MapViewOfFile(paramHandle, FILE_MAP_READ, 0, 0, 0); paramp = MapViewOfFile(paramHandle, FILE_MAP_READ, 0, 0, 0);
if (!paramp) if (!paramp)
{ {
......
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