From 918cf625cc87961903db34e993e570abd6457dcf Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 15 Nov 2017 18:13:00 +0100 Subject: [PATCH] Issue #1958 Blocking timeout spurious wakeups (#1975) * Issue #1958 Blocking timeout Use tryFillInterested to allow retries on spurious wakeups Signed-off-by: Greg Wilkins --- .../java/org/eclipse/jetty/server/HttpConnection.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index 6011d7eff0b..b7f51632dd7 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -564,7 +564,15 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http public void blockingReadFillInterested() { - getEndPoint().fillInterested(_blockingReadCallback); + // We try fillInterested here because of SSL and + // spurious wakeups. With blocking reads, we read in a loop + // that tries to read/parse content and blocks waiting if there is + // none available. The loop can be woken up by incoming encrypted + // bytes, which due to SSL might not produce any decrypted bytes. + // Thus the loop needs to register fill interest again. However if + // the loop is woken up spuriously, then the register interest again + // can result in a pending read exception, unless we use tryFillInterested. + getEndPoint().tryFillInterested(_blockingReadCallback); } public void blockingReadFailure(Throwable e)