pgpool2.git / summary / log / commit / refs

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

    Fix core dump with the following scenario.
      1. detach a node.
      2. create connection pool
      3. attach the node.
      4. reuse the connection pool


pool_connection_pool.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pool_connection_pool.c b/pool_connection_pool.c index a9a96aa95..37482712f 100644 --- a/pool_connection_pool.c +++ b/pool_connection_pool.c @@ -120,9 +120,17 @@ POOL_CONNECTION_POOL *pool_get_cp(char *user, char *database, int protoMajor, in if (!VALID_BACKEND(j)) continue; - sock_broken = check_socket_status(CONNECTION(p, j)->fd); - if (sock_broken < 0) + if (CONNECTION_SLOT(p, j)) + { + sock_broken = check_socket_status(CONNECTION(p, j)->fd); + if (sock_broken < 0) + break; + } + else + { + sock_broken = -1; break; + } } if (sock_broken < 0) @@ -130,7 +138,7 @@ POOL_CONNECTION_POOL *pool_get_cp(char *user, char *database, int protoMajor, in pool_log("connection closed. retry to create new connection pool."); for (j=0;j<NUM_BACKENDS;j++) { - if (!VALID_BACKEND(j)) + if (!VALID_BACKEND(j) || (CONNECTION_SLOT(p, j) == NULL)) continue; if (!freed) @@ -146,9 +154,11 @@ POOL_CONNECTION_POOL *pool_get_cp(char *user, char *database, int protoMajor, in memset(p, 0, sizeof(POOL_CONNECTION_POOL_SLOT)); p->info = info; memset(p->info, 0, sizeof(ConnectionInfo)); + POOL_SETMASK(&oldmask); return NULL; } } + POOL_SETMASK(&oldmask); return p; } p++; [parent: 2df0b1f382ff]