lchqlchq commented on code in PR #2047: URL: https://github.com/apache/zookeeper/pull/2047#discussion_r1349442482
########## zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java: ########## @@ -256,8 +256,8 @@ SocketChannel createSock() throws IOException { * @throws IOException */ void registerAndConnect(SocketChannel sock, InetSocketAddress addr) throws IOException { - sockKey = sock.register(selector, SelectionKey.OP_CONNECT); boolean immediateConnect = sock.connect(addr); + sockKey = sock.register(selector, SelectionKey.OP_CONNECT); Review Comment: Thanks for review. I agree with your viewpoint on the reason of fd leak. if skip register we can not get the sockKey that the primeConnection() is based of in the follow-up actions. And this just register a SelectionKey.OP_CONNECT event,it will not affect primeConnection() implements that will alter the interestOps with "clientCnxnSocket.enableReadWriteOnly()". ########## zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxnSocketNIO.java: ########## @@ -256,8 +256,8 @@ SocketChannel createSock() throws IOException { * @throws IOException */ void registerAndConnect(SocketChannel sock, InetSocketAddress addr) throws IOException { - sockKey = sock.register(selector, SelectionKey.OP_CONNECT); boolean immediateConnect = sock.connect(addr); + sockKey = sock.register(selector, SelectionKey.OP_CONNECT); Review Comment: Thanks for review. I agree with your viewpoint on the reason of fd leak. if skip register we can not get the sockKey that the primeConnection() is based of in the follow-up actions. And this just register a SelectionKey.OP_CONNECT event,it will not affect primeConnection() implements that will alter the interestOps with "clientCnxnSocket.enableReadWriteOnly()". -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org