zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cami...@apache.org
Subject svn commit: r1293975 - in /zookeeper/branches/branch-3.3: CHANGES.txt src/java/main/org/apache/zookeeper/ClientCnxn.java
Date Mon, 27 Feb 2012 00:06:52 GMT
Author: camille
Date: Mon Feb 27 00:06:51 2012
New Revision: 1293975

URL: http://svn.apache.org/viewvc?rev=1293975&view=rev
Log:
ZOOKEEPER-1309. Creating a new ZooKeeper client can leak file handles (Daniel Lord via camille)

Modified:
    zookeeper/branches/branch-3.3/CHANGES.txt
    zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/ClientCnxn.java

Modified: zookeeper/branches/branch-3.3/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/CHANGES.txt?rev=1293975&r1=1293974&r2=1293975&view=diff
==============================================================================
--- zookeeper/branches/branch-3.3/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.3/CHANGES.txt Mon Feb 27 00:06:51 2012
@@ -21,6 +21,8 @@ BUGFIXES:
   ZOOKEEPER-1352. server.InvalidSnapshotTest is using connection timeouts 
   that are too short. (phunt via mahadev)
 
+  ZOOKEEPER-1309. Creating a new ZooKeeper client can leak file handles. (Daniel Lord via
camille)
+  
 IMPROVEMENTS:
 
   ZOOKEEPER-1389. it would be nice if start-foreground used exec $JAVA

Modified: zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/ClientCnxn.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/ClientCnxn.java?rev=1293975&r1=1293974&r2=1293975&view=diff
==============================================================================
--- zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/ClientCnxn.java (original)
+++ zookeeper/branches/branch-3.3/src/java/main/org/apache/zookeeper/ClientCnxn.java Mon Feb
27 00:06:51 2012
@@ -40,9 +40,6 @@ import org.apache.jute.BinaryInputArchiv
 import org.apache.jute.BinaryOutputArchive;
 import org.apache.jute.Record;
 import org.apache.log4j.Logger;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.AsyncCallback.ACLCallback;
 import org.apache.zookeeper.AsyncCallback.Children2Callback;
 import org.apache.zookeeper.AsyncCallback.ChildrenCallback;
@@ -158,8 +155,6 @@ public class ClientCnxn {
 
     final EventThread eventThread;
 
-    final Selector selector = Selector.open();
-
     /**
      * Set to true when close is called. Latches the connection such that we
      * don't attempt to re-connect to the server if in the middle of closing the
@@ -694,6 +689,8 @@ public class ClientCnxn {
     class SendThread extends Thread {
         SelectionKey sockKey;
 
+        private final Selector selector = Selector.open();
+
         final ByteBuffer lenBuffer = ByteBuffer.allocateDirect(4);
 
         ByteBuffer incomingBuffer = lenBuffer;
@@ -939,7 +936,7 @@ public class ClientCnxn {
             }
         }
 
-        SendThread() {
+        SendThread() throws IOException {
             super(makeThreadName("-SendThread()"));
             zooKeeper.state = States.CONNECTING;
             setUncaughtExceptionHandler(uncaughtExceptionHandler);
@@ -1285,6 +1282,10 @@ public class ClientCnxn {
                selector.wakeup();
             }
         }
+
+        synchronized private void wakeup() {
+            selector.wakeup();
+        }
     }
 
     /**
@@ -1373,9 +1374,8 @@ public class ClientCnxn {
                 outgoingQueue.add(packet);
             }
         }
-        synchronized (sendThread) {
-            selector.wakeup();
-        }
+
+        sendThread.wakeup();
         return packet;
     }
 



Mime
View raw message