From 5794584aeab5feb0e05df71ca465ffe3d8148e4b Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 26 Dec 2019 18:57:00 +0100 Subject: [PATCH] Fixes #4444 - Connection timeout intermittently when using jetty 9.4.25. Fixed handling of encrypted bytes to write in needsFillInterest() when the TLS handshake status is NOT_HANDSHAKING. Signed-off-by: Simone Bordet --- .../org/eclipse/jetty/io/ssl/SslConnection.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java index bb202a8f72b..465a3ac8eb9 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ssl/SslConnection.java @@ -862,6 +862,11 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr { interest = true; _fillState = FillState.INTERESTED; + if (_flushState == FlushState.IDLE && BufferUtil.hasContent(_encryptedOutput)) + { + _flushState = FlushState.WRITING; + write = _encryptedOutput; + } } break; @@ -1489,19 +1494,23 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr public void succeeded() { boolean fillable; + boolean interested; synchronized (_decryptedEndPoint) { if (LOG.isDebugEnabled()) LOG.debug("IncompleteWriteCB succeeded {}", SslConnection.this); - releaseEncryptedOutputBuffer(); _flushState = FlushState.IDLE; + + interested = _fillState == FillState.INTERESTED; fillable = _fillState == FillState.WAIT_FOR_FLUSH; if (fillable) _fillState = FillState.IDLE; } - if (fillable) + if (interested) + ensureFillInterested(); + else if (fillable) _decryptedEndPoint.getFillInterest().fillable(); _decryptedEndPoint.getWriteFlusher().completeWrite(); @@ -1520,7 +1529,8 @@ public class SslConnection extends AbstractConnection implements Connection.Upgr releaseEncryptedOutputBuffer(); _flushState = FlushState.IDLE; - failFillInterest = _fillState == FillState.WAIT_FOR_FLUSH; + failFillInterest = _fillState == FillState.WAIT_FOR_FLUSH || + _fillState == FillState.INTERESTED; if (failFillInterest) _fillState = FillState.IDLE; }