pgpool2.git / summary / log / commit / refs

commit    51b4919d2f7f6330ecc437d6fc755086ef7d1e29
Author:   Yoshiyuki Asaba <y-asaba at pgfoundry.org>
Date:     Thu Mar 27 16:04:01 2008 +0000

    Fix a race condition between SIGUSR2 signal and pause().


pcp_child.c | 5 +++-- recovery.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pcp_child.c b/pcp_child.c index 07ae29b0e..7e5ab497c 100644 --- a/pcp_child.c +++ b/pcp_child.c @@ -71,7 +71,8 @@ static RETSIGTYPE reload_config_handler(int sig); extern int myargc; extern char **myargv; -volatile sig_atomic_t pcp_got_sighup = 0; +static volatile sig_atomic_t pcp_got_sighup = 0; +volatile sig_atomic_t pcp_wakeup_request = 0; void pcp_do_child(int unix_fd, int inet_fd, char *pcp_conf_file) @@ -835,7 +836,7 @@ die(int sig) static RETSIGTYPE wakeup_handler(int sig) { - + pcp_wakeup_request = 1; } static PCP_CONNECTION * diff --git a/recovery.c b/recovery.c index a516ede7d..ac39838cd 100644 --- a/recovery.c +++ b/recovery.c @@ -44,6 +44,8 @@ static int check_postmaster_started(BackendInfo *backend); static char recovery_command[1024]; +extern volatile sig_atomic_t pcp_wakeup_request; + int start_recovery(int recovery_node) { BackendInfo *backend; @@ -133,7 +135,15 @@ int start_recovery(int recovery_node) pool_log("%d node restarted", recovery_node); send_failback_request(recovery_node); - pause(); /* wait for failback */ + + /* wait for failback */ + while (!pcp_wakeup_request) + { + struct timeval t = {1, 0}; + /* polling SIGUSR2 signal per 1 sec */ + select(0, NULL, NULL, NULL, &t); + } + pcp_wakeup_request = 0; PQfinish(conn); [parent: ad491f8e1187]