From 23a6a6dc70e8acc94c9326079880cd9bf00ad033 Mon Sep 17 00:00:00 2001 From: Flavia Rainone Date: Tue, 26 Sep 2023 03:18:58 -0300 Subject: [PATCH] [UNDERTOW-2304] Prevent repeating SslConduit.doUnwrap under task thread exhaustion conditions Signed-off-by: Flavia Rainone --- .../src/main/java/io/undertow/protocols/ssl/SslConduit.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/io/undertow/protocols/ssl/SslConduit.java b/core/src/main/java/io/undertow/protocols/ssl/SslConduit.java index c627256c01..398831608d 100644 --- a/core/src/main/java/io/undertow/protocols/ssl/SslConduit.java +++ b/core/src/main/java/io/undertow/protocols/ssl/SslConduit.java @@ -122,6 +122,7 @@ public class SslConduit implements StreamSourceConduit, StreamSinkConduit { private static final int FLAG_CLOSED = 1 << 12; private static final int FLAG_WRITE_CLOSED = 1 << 13; private static final int FLAG_READ_CLOSED = 1 << 14; + public static final ByteBuffer EMPTY_BUFFER = ByteBuffer.allocate(0); /** @@ -1142,14 +1143,13 @@ public void run() { task.run(); } finally { synchronized (SslConduit.this) { - if (outstandingTasks == 1) { + if (outstandingTasks-- == 1) { getWriteThread().execute(new Runnable() { @Override public void run() { synchronized (SslConduit.this) { SslConduit.this.notifyAll(); - --outstandingTasks; try { doHandshake(); } catch (IOException | RuntimeException | Error e) { @@ -1165,8 +1165,6 @@ public void run() { } } }); - } else { - outstandingTasks--; } } }