activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject [activemq] branch main updated: AMQ-8287 - fix NIOSSLTransport deadlock with serviceRead lock
Date Wed, 02 Jun 2021 17:53:46 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new 2fcf2fd  AMQ-8287 - fix NIOSSLTransport deadlock with serviceRead lock
     new ac27cc2  Merge branch 'AMQ-8287' into main
2fcf2fd is described below

commit 2fcf2fd75f7c2a04151a2284595a08bf4c03240b
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@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
---
 .../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);

Mime
View raw message