Fix for 0000249: watchdog sometimes fails de-escalation.
authorMuhammad Usama <m.usama@gmail.com>
Wed, 4 Jan 2017 13:23:33 +0000 (18:23 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Wed, 4 Jan 2017 13:23:33 +0000 (18:23 +0500)
The logic in pgpool-II main process exit_handler and terminate_all_childrens was
not making sure that pgpool-II main process should only exit after all its
children have exited. And the problem occurs when the main process shutdowns
itself before watchdog and de-escalation child processes.

The solution is to use the waitpid() system call without WNOHANG option.

src/main/pgpool_main.c

index 56d58d0533913ce8759b10cdf96047c7138b0f69..f633bba5eb017a09c4a59dc531b3e73823f20aca 100644 (file)
@@ -1076,7 +1076,7 @@ static void terminate_all_childrens()
     {
                int ret_pid;
 
-        wpid = waitpid(-1, &ret_pid, WNOHANG);
+        wpid = waitpid(-1, &ret_pid, 0);
     } while (wpid > 0 || (wpid == -1 && errno == EINTR));
 
     if (wpid == -1 && errno != ECHILD)
@@ -1449,7 +1449,7 @@ static RETSIGTYPE exit_handler(int sig)
     {
                int ret_pid;
 
-        wpid = waitpid(-1, &ret_pid, WNOHANG);
+        wpid = waitpid(-1, &ret_pid, 0);
     } while (wpid > 0 || (wpid == -1 && errno == EINTR));
 
     if (wpid == -1 && errno != ECHILD)