You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/09/01 11:27:06 UTC

[GitHub] [zookeeper] eolivelli commented on a change in pull request #1443: ZOOKEEPER-3916: if zkServer is null, don't accept connection for wasting resource, until not null

eolivelli commented on a change in pull request #1443:
URL: https://github.com/apache/zookeeper/pull/1443#discussion_r481066477



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxnFactory.java
##########
@@ -178,6 +178,14 @@ public void run() {
             try {
                 while (!stopped && !acceptSocket.socket().isClosed()) {
                     try {
+                        /** if zkServer is null, don't accept the connection, until not null.
+                         *  if accept the connection, when reading data from socket, it will be closed by null of zkServer
+                         *
+                         */
+                        if (zkServer == null) {

Review comment:
       shall we sleep a little time ?
   otherwise we are in a busy loop

##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxnFactory.java
##########
@@ -820,7 +828,12 @@ private void addCnxn(NIOServerCnxn cnxn) throws IOException {
     }
 
     protected NIOServerCnxn createConnection(SocketChannel sock, SelectionKey sk, SelectorThread selectorThread) throws IOException {
-        return new NIOServerCnxn(zkServer, sock, sk, this, selectorThread);
+        if (zkServer != null) {

Review comment:
       given your fix above, is this check still useful ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org