hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r822816 - in /hadoop/zookeeper/trunk: CHANGES.txt src/c/src/zookeeper.c
Date Wed, 07 Oct 2009 18:10:51 GMT
Author: mahadev
Date: Wed Oct  7 18:10:50 2009
New Revision: 822816

URL: http://svn.apache.org/viewvc?rev=822816&view=rev
Log:
ZOOKEEPER-542. c-client can spin when server unresponsive (Christian Wiedmann via mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/c/src/zookeeper.c

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=822816&r1=822815&r2=822816&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Wed Oct  7 18:10:50 2009
@@ -82,6 +82,9 @@
   ZOOKEEPER-538. zookeeper.async causes python to segfault
   (henry robinson via phunt)
 
+  ZOOKEEPER-542. c-client can spin when server unresponsive (Christian
+  Wiedmann via mahadev)
+ 
 IMPROVEMENTS:
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
   "socket reuse" and failure to close client (phunt via mahadev)

Modified: hadoop/zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/zookeeper.c?rev=822816&r1=822815&r2=822816&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ hadoop/zookeeper/trunk/src/c/src/zookeeper.c Wed Oct  7 18:10:50 2009
@@ -1353,6 +1353,9 @@
             rc = connect(zh->fd, &zh->addrs[zh->connect_index],
                     sizeof(struct sockaddr));
             if (rc == -1) {
+                /* we are handling the non-blocking connect according to
+                 * the description in section 16.3 "Non-blocking connect"
+                 * in UNIX Network Programming vol 1, 3rd edition */
                 if (errno == EWOULDBLOCK || errno == EINPROGRESS)
                     zh->state = ZOO_CONNECTING_STATE;
                 else
@@ -1412,7 +1415,10 @@
             zh->next_deadline.tv_usec = zh->next_deadline.tv_usec % 1000000;
         }
         *interest = ZOOKEEPER_READ;
-        if (zh->to_send.head || zh->state == ZOO_CONNECTING_STATE) {
+        /* we are interested in a write if we are connected and have something
+         * to send, or we are waiting for a connect to finish. */
+        if ((zh->to_send.head && (zh->state == ZOO_CONNECTED_STATE))
+	    || zh->state == ZOO_CONNECTING_STATE) {
             *interest |= ZOOKEEPER_WRITE;
         }
     }
@@ -1427,6 +1433,9 @@
         int rc, error;
         socklen_t len = sizeof(error);
         rc = getsockopt(zh->fd, SOL_SOCKET, SO_ERROR, &error, &len);
+        /* the description in section 16.4 "Non-blocking connect"
+         * in UNIX Network Programming vol 1, 3rd edition, points out
+         * that sometimes the error is in errno and sometimes in error */
         if (rc < 0 || error) {
             if (rc == 0)
                 errno = error;



Mime
View raw message