aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2023-03-17 09:44:42 +1300
committerThomas Munro <tmunro@postgresql.org>2023-03-17 09:54:03 +1300
commit798dae9f65e379c0f4f22d7a6096287ea50ffb41 (patch)
tree2a8666086a93c76bf05183abc2cf29300da6b1f6
parent9f1c64018549e28a6f6aa5ad0d5917085520efdd (diff)
downloadpostgresql-798dae9f65e379c0f4f22d7a6096287ea50ffb41.tar.gz
postgresql-798dae9f65e379c0f4f22d7a6096287ea50ffb41.zip
Small tidyup for commit d41a178b.
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 d41a178b. Discussion: https://postgr.es/m/CA%2BhUKG%2BpdM9v3Jv4tc2BFx2jh_daY3uzUyAGBhtDkotEQDNPYw%40mail.gmail.com
-rw-r--r--src/backend/postmaster/postmaster.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index dd17d78cdde..56f9f272cae 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -4876,13 +4876,10 @@ retry:
/*
* Queue a waiter to signal when this child dies. The wait will be handled
- * automatically by an operating system thread pool.
- *
- * Note: use malloc instead of palloc, since it needs to be thread-safe.
- * Struct will be free():d from the callback function that runs on a
- * different thread.
+ * automatically by an operating system thread pool. The memory will be
+ * freed by a later call to waitpid().
*/
- childinfo = malloc(sizeof(win32_deadchild_waitinfo));
+ childinfo = palloc(sizeof(win32_deadchild_waitinfo));
if (!childinfo)
ereport(FATAL,
(errcode(ERRCODE_OUT_OF_MEMORY),
@@ -6603,7 +6600,7 @@ waitpid(pid_t pid, int *exitstatus, int options)
* Free struct that was allocated before the call to
* RegisterWaitForSingleObject()
*/
- free(childinfo);
+ pfree(childinfo);
return pid;
}