Review Board 1.7.22


ZOOKEEPER-1174 Proposed fix to file descriptor leak

Review Request #1766 - Created Sept. 8, 2011 and updated

Ted Dunning
Reviewers
zookeeper
zookeeper-git
When connect throws an exception, we can leak descriptors.
See test program and description on https://issues.apache.org/jira/browse/ZOOKEEPER-1174
Review request changed
Updated (Sept. 14, 2011, 10:17 p.m.)
  • changed from Proposed fix to file descriptor leak to ZOOKEEPER-1174 Proposed fix to file descriptor leak
Posted (Sept. 15, 2011, 2 a.m.)

   

  
Based on Camille's comments, this needs to change to roughly this:

       try {
            boolean immediateConnect = sock.connect(addr);
            sockKey = sock.register(selector, SelectionKey.OP_CONNECT);
            if (immediateConnect) {
                sendThread.primeConnection();
            }
        } catch (IOException e) {
            LOG.error("Unable to open socket to " + addr);
            sock.close();

I have been travelling which has made it hard to produce a coherent patch.  Let me do that right now.