Fix pgpool child process to obtain process information.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Sat, 9 Apr 2022 06:54:45 +0000 (15:54 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sat, 9 Apr 2022 06:54:45 +0000 (15:54 +0900)
commit1c7603bf1979e416230d006ef8e71810b98f15c4
treeb437e27c2616467f180f9450cb2c6cf8492cec64
parentfa035f3a1243bb4abdb5d5344ea34528f742d8c5
Fix pgpool child process to obtain process information.

ProcesInfo was obtained by using pool_get_process_info(). But this API
is not suitable for child process because:

- does inefficient linear search over all ProcessInfo slots (there are
  num_init_children slots).

- due to race condition the search key pid might not be set or removed
  in the slot. I think it is possible that by the time when child
  process starts execution, the pid is not yet set in the slot in the
  shared memory. Also when child process is killed by parent process,
  it may set pid to 0 before the child process receive kill signal.

So use pool_get_my_process_info() instead of pool_get_process_info().
which just returns the slot by using global variable my_proc_id as a
key and let child process use it.  my_proc_id was set by the parent
process when the child process was spawn.

The call to pool_get_process_info() in child.c was added in v4.3. So
back patch to V4_3_STABLE.
src/protocol/child.c