1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +03:00

Pass MyPMChildSlot as an explicit argument to child process

All the other global variables passed from postmaster to child have
the same value in all the processes, while MyPMChildSlot is more like
a parameter to each child process.

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/a102f15f-eac4-4ff2-af02-f9ff209ec66f@iki.fi
This commit is contained in:
Heikki Linnakangas
2024-11-14 16:12:32 +02:00
parent a78af04270
commit 5b00786857
4 changed files with 33 additions and 22 deletions

View File

@@ -3374,8 +3374,7 @@ BackendStartup(ClientSocket *client_sock)
/* Hasn't asked to be notified about any bgworkers yet */
bn->bgworker_notify = false;
MyPMChildSlot = bn->child_slot;
pid = postmaster_child_launch(bn->bkend_type,
pid = postmaster_child_launch(bn->bkend_type, bn->child_slot,
(char *) &startup_data, sizeof(startup_data),
client_sock);
if (pid < 0)
@@ -3700,8 +3699,7 @@ StartChildProcess(BackendType type)
return NULL;
}
MyPMChildSlot = pmchild->child_slot;
pid = postmaster_child_launch(type, NULL, 0, NULL);
pid = postmaster_child_launch(type, pmchild->child_slot, NULL, 0, NULL);
if (pid < 0)
{
/* in parent, fork failed */
@@ -3878,8 +3876,8 @@ StartBackgroundWorker(RegisteredBgWorker *rw)
(errmsg_internal("starting background worker process \"%s\"",
rw->rw_worker.bgw_name)));
MyPMChildSlot = bn->child_slot;
worker_pid = postmaster_child_launch(B_BG_WORKER, (char *) &rw->rw_worker, sizeof(BackgroundWorker), NULL);
worker_pid = postmaster_child_launch(B_BG_WORKER, bn->child_slot,
(char *) &rw->rw_worker, sizeof(BackgroundWorker), NULL);
if (worker_pid == -1)
{
/* in postmaster, fork failed ... */