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

Commit 6a9229d

Browse files
committed
Small tidyup for commit d41a178.
A comment was left behind claiming that we needed to use malloc() rather than palloc() because the corresponding free would run in another thread, but that's not true anymore. Remove that comment. And, with the reason being gone, we might as well actually use palloc(). Back-patch to supported releases, like d41a178. Discussion: https://postgr.es/m/CA%2BhUKG%2BpdM9v3Jv4tc2BFx2jh_daY3uzUyAGBhtDkotEQDNPYw%40mail.gmail.com
1 parent f170b57 commit 6a9229d

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/backend/postmaster/postmaster.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -4786,13 +4786,10 @@ internal_forkexec(int argc, char *argv[], Port *port)
47864786

47874787
/*
47884788
* Queue a waiter to signal when this child dies. The wait will be handled
4789-
* automatically by an operating system thread pool.
4790-
*
4791-
* Note: use malloc instead of palloc, since it needs to be thread-safe.
4792-
* Struct will be free():d from the callback function that runs on a
4793-
* different thread.
4789+
* automatically by an operating system thread pool. The memory will be
4790+
* freed by a later call to waitpid().
47944791
*/
4795-
childinfo = malloc(sizeof(win32_deadchild_waitinfo));
4792+
childinfo = palloc(sizeof(win32_deadchild_waitinfo));
47964793
if (!childinfo)
47974794
ereport(FATAL,
47984795
(errcode(ERRCODE_OUT_OF_MEMORY),
@@ -6463,7 +6460,7 @@ waitpid(pid_t pid, int *exitstatus, int options)
64636460
* Free struct that was allocated before the call to
64646461
* RegisterWaitForSingleObject()
64656462
*/
6466-
free(childinfo);
6463+
pfree(childinfo);
64676464

64686465
return pid;
64696466
}

0 commit comments

Comments
 (0)