Browse Source

ZOOKEEPER-846. zookeeper client doesn't shut down cleanly on the close call

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@999776 13f79535-47bb-0310-9956-ffa450edef68
Patrick D. Hunt 15 năm trước cách đây
mục cha
commit
f9f2f0f524
2 tập tin đã thay đổi với 9 bổ sung3 xóa
  1. 3 0
      CHANGES.txt
  2. 6 3
      src/java/main/org/apache/zookeeper/ClientCnxn.java

+ 3 - 0
CHANGES.txt

@@ -98,6 +98,9 @@ BUGFIXES:
 
   ZOOKEEPER-831. BookKeeper: Throttling improved for reads (breed via fpj)
 
+  ZOOKEEPER-846. zookeeper client doesn't shut down cleanly on the close call
+  (phunt)
+
 IMPROVEMENTS:
   ZOOKEEPER-724. Improve junit test integration - log harness information 
   (phunt via mahadev)

+ 6 - 3
src/java/main/org/apache/zookeeper/ClientCnxn.java

@@ -1274,8 +1274,6 @@ public class ClientCnxn {
                       + Long.toHexString(getSessionId()));
         }
 
-        closing = true;
-
         try {
             RequestHeader h = new RequestHeader();
             h.setType(ZooDefs.OpCode.closeSession);
@@ -1323,9 +1321,14 @@ public class ClientCnxn {
             packet.ctx = ctx;
             packet.clientPath = clientPath;
             packet.serverPath = serverPath;
-            if (!zooKeeper.state.isAlive()) {
+            if (!zooKeeper.state.isAlive() || closing) {
                 conLossPacket(packet);
             } else {
+                // If the client is asking to close the session then
+                // mark as closing
+                if (h.getType() == OpCode.closeSession) {
+                    closing = true;
+                }
                 outgoingQueue.add(packet);
             }
         }