pgpool2.git / summary / log / commit / refs

commit    d71782dc1f7f74b1774bdf7371e336f62653bcaa
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Mon Sep 10 13:29:47 2007 +0000

    Modfify pool_send_error_message() so that it won't be blocked
    by sending packet to the closing frontend connection.
    Also rename set_non_block() and unset_non_block() to
    pool_sen_non_block() and pool_unset_non_block() respectively
    to make them public functions.


child.c | 21 +++++---------------- pool.h | 4 ++++ pool_process_query.c | 5 +++++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/child.c b/child.c index aeeb30d9c..7538b1b92 100644 --- a/child.c +++ b/child.c @@ -53,11 +53,6 @@ #include "pool_ip.h" #include "md5.h" -#ifdef NONE_BLOCK -static void set_nonblock(int fd); -static void unset_nonblock(int fd); -#endif - void child_exit(int code); static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *timeout); @@ -123,10 +118,10 @@ void do_child(int unix_fd, int inet_fd) #ifdef NONE_BLOCK /* set listen fds to none block */ - set_nonblock(unix_fd); + pool_set_nonblock(unix_fd); if (inet_fd) { - set_nonblock(inet_fd); + pool_set_nonblock(inet_fd); } #endif @@ -200,11 +195,7 @@ void do_child(int unix_fd, int inet_fd) } /* set frontend fd to blocking */ - unset_nonblock(frontend->fd); - -#ifdef NOT_USED - set_nonblock(frontend->fd); -#endif + pool_unset_nonblock(frontend->fd); /* set busy flag and clear child idle timer */ idle = 0; @@ -533,11 +524,10 @@ void do_child(int unix_fd, int inet_fd) * ------------------------------------------------------------------- */ -#ifdef NONE_BLOCK /* * set non-block flag */ -static void set_nonblock(int fd) +void pool_set_nonblock(int fd) { int var; @@ -554,12 +544,11 @@ static void set_nonblock(int fd) child_exit(1); } } -#endif /* * unset non-block flag */ -static void unset_nonblock(int fd) +void pool_unset_nonblock(int fd) { int var; diff --git a/pool.h b/pool.h index bfae3fd96..cd984b7ae 100644 --- a/pool.h +++ b/pool.h @@ -540,4 +540,8 @@ extern const char *get_ps_display(int *displen); extern int start_recovery(int recovery_node); extern void finish_recovery(void); +/* child.c */ +extern void pool_set_nonblock(int fd); +extern void pool_unset_nonblock(int fd); + #endif /* POOL_H */ diff --git a/pool_process_query.c b/pool_process_query.c index 43028c4de..a6e1974d5 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -4088,6 +4088,9 @@ void pool_send_error_message(POOL_CONNECTION *frontend, int protoMajor, { #define MAXDATA 1024 #define MAXMSGBUF 128 + + pool_set_nonblock(frontend->fd); + if (protoMajor == PROTO_MAJOR_V2) { pool_write(frontend, "E", 1); @@ -4157,6 +4160,8 @@ void pool_send_error_message(POOL_CONNECTION *frontend, int protoMajor, } else pool_error("send_error_message: unknown protocol major %d", protoMajor); + + pool_unset_nonblock(frontend->fd); } void pool_send_readyforquery(POOL_CONNECTION *frontend) [parent: 6f2695e33735]