pgpool2.git / summary / log / commit / refs

commit    e4ad2aeea2fd1171cb8df1728efd5221ae834685
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Mon May 23 10:55:36 2011 +0000

    Fix bug with initializing pool_password in daemon mode.
    Patch from Nicolas Thauvin.
    
    To: pgpool-hackers@pgfoundry.org
    Date: Tue, 17 May 2011 17:08:56 +0200
    ------------------------------------------------------------------------
    When in daemon mode, connection hangs when using md5 authentication
    method. The child process in charge of the client goes into an infinite
    loop in pool_get_passwd() while trying to read the pool_passwd file.
    
    The cause of the problem comes from the daemonize() function that closes
    all file descriptors starting from 3, including the file descriptor of
    the pool_passwd file. When pgpool gets to pool_get_passwd, the null
    checks on the passwd_fd variable fail because the variable was not reset
    to a NULL value.


main.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/main.c b/main.c index 8e64a4f53..42ba1e95a 100644 --- a/main.c +++ b/main.c @@ -327,23 +327,6 @@ int main(int argc, char **argv) pool_config->logsyslog = 1; } - - /* - * Locate pool_passwd - */ - if (strcmp("", pool_config->pool_passwd)) - { - char pool_passwd[POOLMAXPATHLEN+1]; - char dirnamebuf[POOLMAXPATHLEN+1]; - char *dirp; - - strncpy(dirnamebuf, conf_file, sizeof(dirnamebuf)); - dirp = dirname(dirnamebuf); - snprintf(pool_passwd, sizeof(pool_passwd), "%s/%s", - dirp, pool_config->pool_passwd); - pool_init_pool_passwd(pool_passwd); - } - /* * Override debug level */ @@ -426,6 +409,22 @@ int main(int argc, char **argv) else daemonize(); + /* + * Locate pool_passwd + */ + if (strcmp("", pool_config->pool_passwd)) + { + char pool_passwd[POOLMAXPATHLEN+1]; + char dirnamebuf[POOLMAXPATHLEN+1]; + char *dirp; + + strncpy(dirnamebuf, conf_file, sizeof(dirnamebuf)); + dirp = dirname(dirnamebuf); + snprintf(pool_passwd, sizeof(pool_passwd), "%s/%s", + dirp, pool_config->pool_passwd); + pool_init_pool_passwd(pool_passwd); + } + if (pool_semaphore_create(MAX_NUM_SEMAPHORES)) { pool_error("Unable to create semaphores. Exiting..."); [parent: 1f0d3d613b84]