wujimin commented on a change in pull request #824: [SCB-687] add highway 
server connection protection
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/824#discussion_r203929543
 
 

 ##########
 File path: 
foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/server/TcpServer.java
 ##########
 @@ -57,8 +69,18 @@ public void init(Vertx vertx, String sslKey, 
AsyncResultCallback<InetSocketAddre
     }
 
     netServer.connectHandler(netSocket -> {
-      TcpServerConnection connection = createTcpServerConnection();
-      connection.init(netSocket);
+      if (connectedCounter.get() < connectionLimit) {
 
 Review comment:
   seems this is more clear.
   ```
   if (connectedCounter.incrementAndGet() > connectionLimit){
     connectedCounter.decrementAndGet();
     netSocket.close();
     return;
   }
   
   TcpServerConnection connection = createTcpServerConnection();
   connection.init(netSocket, connectedCounter);
   EventManager.post(new ClientConnectedEvent(netSocket, connectedCount));
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to