clebertsuconic commented on a change in pull request #2759: ARTEMIS-2408 Too 
many opened FDs after server stops
URL: https://github.com/apache/activemq-artemis/pull/2759#discussion_r304948383
 
 

 ##########
 File path: 
artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
 ##########
 @@ -407,15 +410,28 @@ public void stop(final boolean criticalError) throws 
Exception {
          conn.disconnect(criticalError);
       }
 
+      Map<Acceptor, Future<?>> acceptorFutures = new HashMap<>();
       for (Acceptor acceptor : acceptors.values()) {
          try {
-            acceptor.stop();
+            //In some cases an acceptor stopping could be locked ie 
NettyAcceptor stopping could be locked by a network failure.
+            acceptorFutures.put(acceptor, acceptor.asyncStop());
 
 Review comment:
   it would be a lot simpler if instead of returning a future, you passed in a 
Runnable or Future
   
   You could have the following code:
   
   ```java
   // Instead of a Map<Acceptor, Future>
   CountDownLatch latch = new CountDownLatch(acceptors.size());
   
   for (Acceptor accetor: acceptors.values()) {
       acceptor.asyncStop(latch::countDown);
   }
   ```
   
   and the whole loop on each Future would be replaced by:
   ```java
      latch.await(3, TimeUnit.Seconds);
   ```
   
   
   You could also use ReusableLatch, and call countUp during the acceptor loop.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to