You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2016/04/25 15:49:16 UTC

[1/2] activemq-artemis git commit: This closes #480

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 224e04969 -> 00740b141


This closes #480


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/00740b14
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/00740b14
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/00740b14

Branch: refs/heads/master
Commit: 00740b141a3afd4dc3ff1621d2630ae7d3cfcced
Parents: 224e049 971a0a1
Author: Martyn Taylor <mt...@redhat.com>
Authored: Mon Apr 25 14:48:58 2016 +0100
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Mon Apr 25 14:48:58 2016 +0100

----------------------------------------------------------------------
 .../remoting/impl/netty/NettyConnection.java    | 26 +++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------



[2/2] activemq-artemis git commit: ARTEMIS-497 Prevent 10 second stalls when closing an SSL connection

Posted by ma...@apache.org.
ARTEMIS-497 Prevent 10 second stalls when closing an SSL connection

When NettyConnection.classSSLAndChannel is called from the EventLoop,
waiting for the SSL handler to close will always take 10 seconds, because
the sslCloseFuture is from a task that is scheduled with the same
EventLoop. But since the EventLoop is a single threaded executor, it
will only be executed after the current task is completed.

Due to the single threaded nature of the EventLoop, all blocking calls
should be avoided. Therefore, I removed both awaitUninterruptibly calls
if the closing happens within an event loop tasks. As a side effect,
the annoying server log timeout warnings will go away.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/971a0a13
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/971a0a13
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/971a0a13

Branch: refs/heads/master
Commit: 971a0a13bdff8130fb868c3a357e36586d6d56f0
Parents: 224e049
Author: Bernd Gutjahr <be...@hpe.com>
Authored: Fri Apr 22 08:22:41 2016 +0200
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Mon Apr 25 14:48:58 2016 +0100

----------------------------------------------------------------------
 .../remoting/impl/netty/NettyConnection.java    | 26 +++++++++++++-------
 1 file changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/971a0a13/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
index 6947883..a8c80c6 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnection.java
@@ -29,6 +29,8 @@ import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelPromise;
 import io.netty.channel.EventLoop;
 import io.netty.handler.ssl.SslHandler;
+import io.netty.util.concurrent.GenericFutureListener;
+
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
 import org.apache.activemq.artemis.api.core.ActiveMQInterruptedException;
@@ -193,13 +195,13 @@ public class NettyConnection implements Connection {
       boolean inEventLoop = eventLoop.inEventLoop();
       //if we are in an event loop we need to close the channel after the writes have finished
       if (!inEventLoop) {
-         closeSSLAndChannel(sslHandler, channel);
+         closeSSLAndChannel(sslHandler, channel, false);
       }
       else {
          eventLoop.execute(new Runnable() {
             @Override
             public void run() {
-               closeSSLAndChannel(sslHandler, channel);
+               closeSSLAndChannel(sslHandler, channel, true);
             }
          });
       }
@@ -412,12 +414,17 @@ public class NettyConnection implements Connection {
 
    // Private -------------------------------------------------------
 
-   private void closeSSLAndChannel(SslHandler sslHandler, Channel channel) {
+   private void closeSSLAndChannel(SslHandler sslHandler, final Channel channel, boolean inEventLoop) {
       if (sslHandler != null) {
          try {
             ChannelFuture sslCloseFuture = sslHandler.close();
-
-            if (!sslCloseFuture.awaitUninterruptibly(10000)) {
+            sslCloseFuture.addListener(new GenericFutureListener<ChannelFuture>() {
+               @Override
+               public void operationComplete(ChannelFuture future) throws Exception {
+                  channel.close();
+               }
+            });
+            if (!inEventLoop && !sslCloseFuture.awaitUninterruptibly(10000)) {
                ActiveMQClientLogger.LOGGER.timeoutClosingSSL();
             }
          }
@@ -425,10 +432,11 @@ public class NettyConnection implements Connection {
             // ignore
          }
       }
-
-      ChannelFuture closeFuture = channel.close();
-      if (!closeFuture.awaitUninterruptibly(10000)) {
-         ActiveMQClientLogger.LOGGER.timeoutClosingNettyChannel();
+      else {
+         ChannelFuture closeFuture = channel.close();
+         if (!inEventLoop && !closeFuture.awaitUninterruptibly(10000)) {
+            ActiveMQClientLogger.LOGGER.timeoutClosingNettyChannel();
+         }
       }
    }
    // Inner classes -------------------------------------------------