pgpool2.git / summary / log / commit / refs
commit ee0bac759857599023da9268d82c05604b759a64
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Mon Oct 29 12:35:57 2012 +0000
Fix race condition when using pool_get_passwd. The file descriptor to
pool_passwd is opened in pgpool main and pgpool child inherits
it. When concurrent connections try to authenticate md5 method, they
call pool_get_passwd and seek the fd and cause random md5 auth failure
because underlying fd is shared. Fix is, let individual pgpool child
open the file by calling pool_reopen_passwd_file.
Problem reported and analyzed by Jason Slagle in pgpool-general:1141.
child.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/child.c b/child.c
index f5ccc53c6..6a4300e1f 100644
--- a/child.c
+++ b/child.c
@@ -156,6 +156,15 @@ void do_child(int unix_fd, int inet_fd)
child_exit(1);
}
+ /*
+ * Open pool_passwd in child process. This is necessary to avoid the
+ * file descriptor race condition reported in [pgpool-general: 1141].
+ */
+ if (strcmp("", pool_config->pool_passwd))
+ {
+ pool_reopen_passwd_file();
+ }
+
timeout.tv_sec = pool_config->child_life_time;
timeout.tv_usec = 0;
@@ -641,7 +650,8 @@ static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *time
if (pool_config->enable_pool_hba)
{
load_hba(get_hba_file_name());
- pool_reopen_passwd_file();
+ if (strcmp("", pool_config->pool_passwd))
+ pool_reopen_passwd_file();
}
if (pool_config->parallel_mode)
pool_memset_system_db_info(system_db_info->info);
[parent: 4e42e9e83c4f]