pgpool2.git / summary / log / commit / refs
commit bbbcd3ac5dc752a928eb4275d3cb64bdb54a1b73
Author: Muhammad Usama <m.usama@gmail.com>
Date: Sun Jul 23 17:34:05 2023 +0000
Install system exit callback only after initialization of shared memory.
When the on-exit callback gets called because of a failure to acquire
shared memory. The cleanup function can produce a segfault while accessing
process_info, that lives in shared memory.
Although we can also fix this by bailing out from the exit callback when
process_info is NULL but installing the function after successful initialization
of shared memory is a better approach as the rest of the system always assumes
the process_info can never be NULL, and also, there is nothing to
clean up before child processes are spawned.
src/main/pgpool_main.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index 252ea6da2..66c342034 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -313,11 +313,6 @@ PgpoolMain(bool discard_status, bool clear_memcache_oidmaps)
*/
read_status_file(discard_status);
- /*
- * install the call back for preparation of system exit
- */
- on_system_exit(system_will_go_down, (Datum) NULL);
-
/* set unix domain socket path for connections to pgpool */
for (i = 0; i < pool_config->num_unix_socket_directories; i++)
{
@@ -394,6 +389,11 @@ PgpoolMain(bool discard_status, bool clear_memcache_oidmaps)
initialize_shared_mem_objects(clear_memcache_oidmaps);
+ /*
+ * install the callback for preparation of system exit
+ */
+ on_system_exit(system_will_go_down, (Datum) NULL);
+
/* setup signal handlers */
pool_signal(SIGCHLD, reap_handler);
pool_signal(SIGUSR1, sigusr1_handler);
[parent: 212c9b87261e]