pgpool2.git / summary / log / commit / refs

commit    ef8f08730f46d5b1f7869548b2bfe33099b9b66c
Author:   User yamaguti <yamaguti at pgfoundry.org>
Date:     Fri Feb 08 06:47:43 2008 +0000

    Implemented configuration file "reload" function into PCP.


main.c | 4 ++++ pcp_child.c | 25 +++++++++++++++++++------ recovery.c | 4 ++-- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 6e4dd9e63..6c522da08 100644 --- a/main.c +++ b/main.c @@ -1610,6 +1610,10 @@ static void kill_all_children(int sig) kill(pid, sig); } } + + /* make PCP process reload as well */ + if (sig == SIGHUP) + kill(pcp_pid, sig); } /* diff --git a/pcp_child.c b/pcp_child.c index 83fb0a226..07ae29b0e 100644 --- a/pcp_child.c +++ b/pcp_child.c @@ -66,10 +66,13 @@ static void unset_nonblock(int fd); static int user_authenticate(char *buf, char *passwd_file, char *salt, int salt_len); static void pool_random_salt(char *md5Salt); static RETSIGTYPE wakeup_handler(int sig); +static RETSIGTYPE reload_config_handler(int sig); extern int myargc; extern char **myargv; +volatile sig_atomic_t pcp_got_sighup = 0; + void pcp_do_child(int unix_fd, int inet_fd, char *pcp_conf_file) { @@ -97,7 +100,7 @@ pcp_do_child(int unix_fd, int inet_fd, char *pcp_conf_file) /* set up signal handlers */ signal(SIGTERM, die); signal(SIGINT, die); - signal(SIGHUP, die); + signal(SIGHUP, reload_config_handler); signal(SIGQUIT, die); signal(SIGCHLD, SIG_DFL); signal(SIGUSR1, SIG_DFL); @@ -113,10 +116,8 @@ pcp_do_child(int unix_fd, int inet_fd, char *pcp_conf_file) { frontend = pcp_do_accept(unix_fd, inet_fd); if (frontend == NULL) - { - /* pcp_do_accept() calls pool_error(), so just exit */ - exit(1); - } + continue; + unset_nonblock(frontend->fd); } @@ -894,6 +895,12 @@ pcp_do_accept(int unix_fd, int inet_fd) return NULL; } + if (pcp_got_sighup) + { + pool_get_config(get_config_file_name(), RELOAD_CONFIG); + pcp_got_sighup = 0; + } + pool_debug("I am PCP %d accept fd %d", getpid(), afd); if (inet) @@ -934,7 +941,7 @@ unset_nonblock(int fd) { int var; - /* set fd to none blocking */ + /* set fd to non-blocking */ var = fcntl(fd, F_GETFL, 0); if (var == -1) { @@ -1058,3 +1065,9 @@ static void pool_random_salt(char *md5Salt) rand = random(); md5Salt[3] = (rand % 255) + 1; } + +/* SIGHUP handler */ +static RETSIGTYPE reload_config_handler(int sig) +{ + pcp_got_sighup = 1; +} diff --git a/recovery.c b/recovery.c index ff8a21b18..ddb6c86c1 100644 --- a/recovery.c +++ b/recovery.c @@ -268,7 +268,7 @@ static int check_postmaster_started(BackendInfo *backend) sleep(3); } while (i++ < WAIT_RETRY_COUNT); - pool_error("check_postmaster_started: remote host start up did not finish in %d sec.", WAIT_RETRY_COUNT); + pool_error("check_postmaster_started: remote host start up did not finish in %d sec.", pool_config->recovery_timeout); return 1; } @@ -311,6 +311,6 @@ static int wait_connection_closed(void) sleep(3); } while (i++ < WAIT_RETRY_COUNT); - pool_error("wait_connection_closed: existing connections did not close in %d sec.", WAIT_RETRY_COUNT); + pool_error("wait_connection_closed: existing connections did not close in %d sec.", pool_config->recovery_timeout); return 1; } [parent: 7b3ba34bc1ce]