pgpool2.git / summary / log / commit / refs
commit d3ea5b540db3c36625e0ce1dd89081d7f91e7906
Author: Yugo Nagata <nagata@sraoss.co.jp>
Date: Sun May 12 23:12:17 2013 +0000
Fix wd_create_send_socket() not to execute select() before connect()
How select() works on an unconnected socket is undefined, and differs
between platform. This returns 2 on Linux and it is eventually harmless.
However, this returns 0 on Solaris and it is indistinguishable from time
timeout.
watchdog/wd_packet.c | 51 ++++-----------------------------------------------
1 file changed, 4 insertions(+), 47 deletions(-)
diff --git a/watchdog/wd_packet.c b/watchdog/wd_packet.c
index a9ef623c0..09d1953b7 100644
--- a/watchdog/wd_packet.c
+++ b/watchdog/wd_packet.c
@@ -219,54 +219,11 @@ wd_create_send_socket(char * hostname, int port)
/* try to connect */
for (;;)
{
- fd_set wmask;
- fd_set emask;
- struct timeval timeout;
- int sockErrVal = 0;
- int rtn;
- socklen_t sockErrValLen = sizeof(int);
-
- timeout.tv_sec = WD_SEND_TIMEOUT;
- timeout.tv_usec = 0;
-
- FD_ZERO(&wmask);
- FD_ZERO(&emask);
- FD_SET(sock,&wmask);
- FD_SET(sock,&emask);
-
- rtn = select(sock+1, NULL, &wmask, &emask, &timeout );
- if ( rtn < 0 )
- {
- if ( errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK )
- {
- continue;
- }
- /* connection failed */
- break;
- }
- else if ( rtn == 0 )
- {
- /* timeout */
- break;
- }
- else if ( FD_ISSET(sock, &emask) )
- {
- /* socket exception occured */
- break;
- }
-
- if ( getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*)&sockErrVal, &sockErrValLen) == 0 && sockErrVal != 0 )
- {
- /* error occured on this socket while connecting to target */
- break;
- }
-
- rtn = connect(sock,(struct sockaddr*)&addr, len);
- if ( rtn < 0 )
+ if (connect(sock,(struct sockaddr*)&addr, len) < 0)
{
- if ( errno == EINPROGRESS || errno == EALREADY || errno == EWOULDBLOCK || errno == EINTR || errno == 0 )
+ if (errno == EINTR)
continue;
- else if ( errno == EISCONN )
+ else if (errno == EISCONN)
{
return sock;
}
@@ -965,7 +922,7 @@ wd_escalation(void)
rtn = wd_declare();
if (rtn == WD_OK)
{
- pool_log("wd_escalation: escalated to delegate_IP holder");
+ pool_log("wd_escalation: escalated to delegate_IP holder");
}
return rtn;
[parent: 10bb79467edc]