pgpool2.git / summary / log / commit / refs

commit    d3850a02cc478f62df74e2f629faa8444047fe0c
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Sun Sep 06 03:56:37 2009 +0000

    Fix connection_count_down() so that it does decrement too much in some
    corner cases.  If failed to read a start up packet, or receive cancel
    request etc., connection_count_down() is called and goes back to the
    onnection accept loop. Problem is, at the very beginning of the
    connection accept loop, if we have received a signal, we call
    child_exit() which calls connection_count_down() again.
    Problem report by Ryoichi TANABE. See [pgpool-general-jp: 616]
    for more details.
    
    Also unneccesary public declarations for connection_count_up() and
    connection_count_down() are removed.


child.c | 25 ++++++++++++++++++++++--- pool.h | 3 --- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/child.c b/child.c index 788ffc7dc..eeb150c66 100644 --- a/child.c +++ b/child.c @@ -68,6 +68,8 @@ static RETSIGTYPE authentication_timeout(int sig); static int send_params(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend); static void send_frontend_exits(void); static int s_do_auth(POOL_CONNECTION_POOL_SLOT *cp, char *password); +static void connection_count_up(void); +static void connection_count_down(void); /* * non 0 means SIGTERM(smart shutdown) or SIGINT(fast shutdown) has arrived @@ -1774,17 +1776,34 @@ static int s_do_auth(POOL_CONNECTION_POOL_SLOT *cp, char *password) return -1; } -void connection_count_up(void) +/* + * Count up connection counter (from frontend to pgpool) + * in shared memory + */ +static void connection_count_up(void) { pool_semaphore_lock(CONN_COUNTER_SEM); Req_info->conn_counter++; pool_semaphore_unlock(CONN_COUNTER_SEM); } -void connection_count_down(void) +/* + * Count down connection counter (from frontend to pgpool) + * in shared memory + */ +static void connection_count_down(void) { pool_semaphore_lock(CONN_COUNTER_SEM); - Req_info->conn_counter--; + /* + * Make sure that we do not decrement too much. If failed to read + * a start up packet, or receive cancel request etc., + * connection_count_down() is called and goes back to the + * connection accept loop. Problem is, at the very beginning of + * the connection accept loop, if we have received a signal, we + * call child_exit() which calls connection_count_down() again. + */ + if (Req_info->conn_counter > 0) + Req_info->conn_counter--; pool_semaphore_unlock(CONN_COUNTER_SEM); } diff --git a/pool.h b/pool.h index 290eb4f9b..e2458bb7c 100644 --- a/pool.h +++ b/pool.h @@ -528,9 +528,6 @@ extern int send_startup_packet(POOL_CONNECTION_POOL_SLOT *cp); extern void pool_free_startup_packet(StartupPacket *sp); extern void child_exit(int code); -extern void connection_count_up(void); -extern void connection_count_down(void); - extern int health_check(void); extern int system_db_health_check(void); [parent: d782bc549321]