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

Commit 4acf99b

Browse files
committed
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.
1 parent 2edc5cd commit 4acf99b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3755,7 +3755,11 @@ internal_forkexec(int argc, char *argv[], Port *port)
37553755
}
37563756

37573757
/* Insert temp file name after --fork argument */
3758+
#ifdef _WIN64
3759+
sprintf(paramHandleStr, "%llu", (LONG_PTR) paramHandle);
3760+
#else
37583761
sprintf(paramHandleStr, "%lu", (DWORD) paramHandle);
3762+
#endif
37593763
argv[2] = paramHandleStr;
37603764

37613765
/* Format the cmd line */
@@ -4825,7 +4829,11 @@ read_backend_variables(char *id, Port *port)
48254829
HANDLE paramHandle;
48264830
BackendParameters *paramp;
48274831

4832+
#ifdef _WIN64
4833+
paramHandle = (HANDLE) _atoi64(id);
4834+
#else
48284835
paramHandle = (HANDLE) atol(id);
4836+
#endif
48294837
paramp = MapViewOfFile(paramHandle, FILE_MAP_READ, 0, 0, 0);
48304838
if (!paramp)
48314839
{

0 commit comments

Comments
 (0)