You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ph...@apache.org on 2013/07/02 00:54:26 UTC

svn commit: r1498732 - in /zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/ClientCnxnSocketNIO.java

Author: phunt
Date: Mon Jul  1 22:54:25 2013
New Revision: 1498732

URL: http://svn.apache.org/r1498732
Log:
ZOOKEEPER-1702. ZooKeeper client may write operation packets before receiving successful response to connection request, can cause TCP RST (Chris Nauroth via phunt)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxnSocketNIO.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1498732&r1=1498731&r2=1498732&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Mon Jul  1 22:54:25 2013
@@ -360,6 +360,10 @@ BUGFIXES:
   
   ZOOKEEPER-1663. scripts don't work when path contains spaces (Amichai Rothman via camille)
 
+  ZOOKEEPER-1702. ZooKeeper client may write operation packets before
+  receiving successful response to connection request, can cause TCP
+  RST (Chris Nauroth via phunt)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxnSocketNIO.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxnSocketNIO.java?rev=1498732&r1=1498731&r2=1498732&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxnSocketNIO.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/ClientCnxnSocketNIO.java Mon Jul  1 22:54:25 2013
@@ -139,6 +139,17 @@ public class ClientCnxnSocketNIO extends
                     // to attempt SASL authentication), or in either doIO() or
                     // in doTransport() if not.
                     disableWrite();
+                } else if (!initialized && p != null && !p.bb.hasRemaining()) {
+                    // On initial connection, write the complete connect request
+                    // packet, but then disable further writes until after
+                    // receiving a successful connection response.  If the
+                    // session is expired, then the server sends the expiration
+                    // response and immediately closes its end of the socket.  If
+                    // the client is simultaneously writing on its end, then the
+                    // TCP stack may choose to abort with RST, in which case the
+                    // client would never receive the session expired event.  See
+                    // http://docs.oracle.com/javase/6/docs/technotes/guides/net/articles/connection_release.html
+                    disableWrite();
                 } else {
                     // Just in case
                     enableWrite();