You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2022/02/08 14:51:18 UTC
[mina] branch 2.0.X updated: Applied a patch pushed in 2.1
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch 2.0.X
in repository https://gitbox.apache.org/repos/asf/mina.git
The following commit(s) were added to refs/heads/2.0.X by this push:
new 6a6e626 Applied a patch pushed in 2.1
6a6e626 is described below
commit 6a6e626eae4d6af2c54cd92168c5346671b45957
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Tue Feb 8 15:51:06 2022 +0100
Applied a patch pushed in 2.1
---
.../java/org/apache/mina/filter/ssl/SslFilter.java | 23 ++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java b/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
index b3b88c6..dde0e64 100644
--- a/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
+++ b/mina-core/src/main/java/org/apache/mina/filter/ssl/SslFilter.java
@@ -22,6 +22,7 @@ package org.apache.mina.filter.ssl;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
@@ -513,14 +514,20 @@ public class SslFilter extends IoFilterAdapter {
}
SslHandler sslHandler = getSslSessionHandler(session);
+ AtomicBoolean canPushMessage = new AtomicBoolean( false );
+
+ // The SslHandler instance is *guaranteed* to not be null here
synchronized (sslHandler) {
- if (!isSslStarted(session) && sslHandler.isInboundDone()) {
- // The SSL session must be established first before we
- // can push data to the application. Store the incoming
- // data into a queue for a later processing
- sslHandler.scheduleMessageReceived(nextFilter, message);
+ if (sslHandler.isOutboundDone() && sslHandler.isInboundDone()) {
+ // We aren't handshaking here. Let's push the message to the next filter
+
+ // Note: we can push the message to the queue immediately,
+ // but don't do so in the synchronized block. We use a protected
+ // flag to do so.
+ canPushMessage.set( true );
} else {
+ canPushMessage.set( false );
IoBuffer buf = (IoBuffer) message;
try {
@@ -565,7 +572,11 @@ public class SslFilter extends IoFilterAdapter {
}
}
- sslHandler.flushMessageReceived();
+ if (canPushMessage.get()) {
+ nextFilter.messageReceived(session, message);
+ } else {
+ sslHandler.flushMessageReceived();
+ }
}
@Override