pgpool2.git / summary / log / commit / refs

commit    2ee501190928f149f67dcb537855071091e27caa
Author:   Tatsuo Ishii <ishii@sraoss.co.jp>
Date:     Sun Sep 17 11:45:46 2023 +0000

    Fix hung up in pcp_exit_handler of pcp child main.
    
    pcp_exit_handler is responsible for waiting for exiting pcp child
    process. I suspect it is hung up in the wait loop in regression test
    001.
    
    https://www.pgpool.net/pipermail/pgpool-hackers/2023-September/004397.html
    
    So I changed it so that it uses waitpid(2) with WNOHANG option.


src/pcp_con/pcp_child.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pcp_con/pcp_child.c b/src/pcp_con/pcp_child.c index 363b6bd30..b1d921141 100644 --- a/src/pcp_con/pcp_child.c +++ b/src/pcp_con/pcp_child.c @@ -406,6 +406,7 @@ static RETSIGTYPE pcp_exit_handler(int sig) { pid_t wpid; + ListCell *lc; POOL_SETMASK(&AuthBlockSig); @@ -420,15 +421,17 @@ pcp_exit_handler(int sig) POOL_SETMASK(&UnBlockSig); - if (list_length(pcp_worker_children) > 0) + foreach(lc, pcp_worker_children) { + int pid; + do { - wpid = wait(NULL); - } while (wpid > 0 || (wpid == -1 && errno == EINTR)); - - list_free(pcp_worker_children); + wpid = (pid_t) lfirst_int(lc); + pid = waitpid(wpid, NULL, WNOHANG); + } while (pid == -1 && errno == EINTR); } + pcp_worker_children = NULL; exit(0); [parent: fb0800e3f021]