10000 Small tidyup for commit d41a178b. · postgres/postgres@9d6c343 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d6c343

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 5ff8e69 commit 9d6c343

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4741,14 +4741,11 @@ internal_forkexec(int argc, char *argv[], Port *port)
47414741
}
47424742

47434743
/*
4744-
* Queue a waiter for to signal when this child dies. The wait will be
4745-
* handled automatically by an operating system thread pool.
4746-
*
4747-
* Note: use malloc instead of palloc, since it needs to be thread-safe.
4748-
* Struct will be free():d from the callback function that runs on a
4749-
* different thread.
4744+
* Queue a waiter to signal when this child dies. The wait will be handled
4745+
* automatically by an operating system thread pool. The memory will be
4746+
* freed by a later call to waitpid().
47504747
*/
4751-
childinfo = malloc(sizeof(win32_deadchild_waitinfo));
4748+
childinfo = palloc(sizeof(win32_deadchild_waitinfo));
47524749
if (!childinfo)
47534750
ereport(FATAL,
47544751
(errcode(ERRCODE_OUT_OF_MEMORY),
@@ -6519,7 +6516,7 @@ waitpid(pid_t pid, int *exitstatus, int options)
65196516
* Free struct that was allocated before the call to
65206517
* RegisterWaitForSingleObject()
65216518
*/
6522-
free(childinfo);
6519+
pfree(childinfo);
65236520

65246521
return pid;
65256522
}

0 commit comments

Comments
 (0)
0