pgpool2.git / summary / log / commit / refs

commit    b1a1c756a563541cc45677f38db5e8b85acd4fab
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Tue Mar 05 23:12:53 2013 +0000

    Fix connect_inet_domain_socket_by_port() to set more appropriate value
    for timeout parameter of select(2). Some platforms such as Solaris do
    not allow to specify too large microseconds timeout value. So divide
    the timeout value to seconds and microseconds.


pool_connection_pool.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pool_connection_pool.c b/pool_connection_pool.c index cc0ba2104..4a1048b41 100644 --- a/pool_connection_pool.c +++ b/pool_connection_pool.c @@ -517,7 +517,11 @@ int connect_inet_domain_socket_by_port(char *host, int port, bool retry) socklen_t socklen; int sts; -#define CONNECT_TIMEOUT_MSEC 1000 /* specify select(2) timeout in millisecond */ +#define CONNECT_TIMEOUT_MSEC 1000 /* specify select(2) timeout in milliseconds */ +#define CONNECT_TIMEOUT_SEC CONNECT_TIMEOUT_MSEC/1000 /* seconds part */ +/* microseconds part */ +#define CONNECT_TIMEOUT_MICROSEC (CONNECT_TIMEOUT_SEC == 0?CONNECT_TIMEOUT_MSEC*1000:\ + CONNECT_TIMEOUT_MSEC*1000 - CONNECT_TIMEOUT_SEC*1000*1000) fd = socket(AF_INET, SOCK_STREAM, 0); @@ -594,8 +598,8 @@ int connect_inet_domain_socket_by_port(char *host, int port, bool retry) return -1; } - timeout.tv_sec = 0; - timeout.tv_usec = CONNECT_TIMEOUT_MSEC * 1000; + timeout.tv_sec = CONNECT_TIMEOUT_SEC; + timeout.tv_usec = CONNECT_TIMEOUT_MICROSEC; FD_ZERO(&rset); FD_SET(fd, &rset); FD_ZERO(&wset); [parent: f5df0a30f70a]