You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cs...@apache.org on 2021/06/02 17:55:08 UTC

[activemq] branch activemq-5.16.x updated: AMQ-8287 - fix NIOSSLTransport deadlock with serviceRead lock

This is an automated email from the ASF dual-hosted git repository.

cshannon pushed a commit to branch activemq-5.16.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.16.x by this push:
     new 0f952f7  AMQ-8287 - fix NIOSSLTransport deadlock with serviceRead lock
0f952f7 is described below

commit 0f952f72f798c5626dcd6270c9282e0e8988bd41
Author: Christopher L. Shannon (cshannon) <ch...@gmail.com>
AuthorDate: Wed Jun 2 09:47:24 2021 -0400

    AMQ-8287 - fix NIOSSLTransport deadlock with serviceRead lock
    
    This narrows the lock that was added to serviceRead() to secureRead()
    which prevents processing commands while locked which should solve the
    deadlock issues
    
    (cherry picked from commit 2fcf2fd75f7c2a04151a2284595a08bf4c03240b)
---
 .../org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java  | 3 +--
 .../java/org/apache/activemq/transport/nio/NIOSSLTransport.java     | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java b/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java
index 98d0d79..e5717ac 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/transport/nio/AutoInitNioSSLTransport.java
@@ -158,9 +158,8 @@ public class AutoInitNioSSLTransport extends NIOSSLTransport {
         return readSize;
     }
 
-    //Prevent concurrent access to SSLEngine
     @Override
-    public synchronized void serviceRead() {
+    public void serviceRead() {
         try {
             if (handshakeInProgress) {
                 doHandshake();
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java b/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java
index 4c944f4..d0e2fc8 100644
--- a/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/nio/NIOSSLTransport.java
@@ -243,9 +243,8 @@ public class NIOSSLTransport extends NIOTransport {
         }
     }
 
-    //Prevent concurrent access to SSLEngine
     @Override
-    public synchronized void serviceRead() {
+    public void serviceRead() {
         try {
             if (handshakeInProgress) {
                 doHandshake();
@@ -374,7 +373,8 @@ public class NIOSSLTransport extends NIOTransport {
         }
     }
 
-    protected int secureRead(ByteBuffer plain) throws Exception {
+    //Prevent concurrent access while reading from the channel
+    protected synchronized int secureRead(ByteBuffer plain) throws Exception {
 
         if (!(inputBuffer.position() != 0 && inputBuffer.hasRemaining()) || status == SSLEngineResult.Status.BUFFER_UNDERFLOW) {
             int bytesRead = channel.read(inputBuffer);