From 8e875ab7a4fbee318e1e7fe3fe59cbeda0b53e9e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Wed, 11 Dec 2019 13:02:23 +0100 Subject: [PATCH] Issue #4411 - Jetty server spins on incomplete request. Updated FastCGI code to pass the test. Signed-off-by: Simone Bordet --- .../eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java | 8 ++++++++ .../eclipse/jetty/fcgi/server/ServerFCGIConnection.java | 8 ++++++++ .../eclipse/jetty/http/client/HttpClientStreamTest.java | 4 ---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java index 1ba90e21ce2..bc7542ed354 100644 --- a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java +++ b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/HttpChannelOverFCGI.java @@ -125,6 +125,14 @@ public class HttpChannelOverFCGI extends HttpChannel dispatcher.dispatch(); } + public boolean onIdleTimeout(Throwable timeout) + { + boolean handle = getRequest().getHttpInput().onIdleTimeout(timeout); + if (handle) + execute(this); + return !handle; + } + private static class Dispatcher implements Runnable { private final AtomicReference state = new AtomicReference<>(State.IDLE); diff --git a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/ServerFCGIConnection.java b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/ServerFCGIConnection.java index 73b45bda8c8..97cfbbd3ff9 100644 --- a/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/ServerFCGIConnection.java +++ b/jetty-fcgi/fcgi-server/src/main/java/org/eclipse/jetty/fcgi/server/ServerFCGIConnection.java @@ -105,6 +105,14 @@ public class ServerFCGIConnection extends AbstractConnection } } + @Override + protected boolean onReadTimeout(Throwable timeout) + { + return channels.values().stream() + .mapToInt(channel -> channel.onIdleTimeout(timeout) ? 0 : 1) + .sum() == 0; + } + private void parse(ByteBuffer buffer) { while (buffer.hasRemaining()) diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java index ac83e55357a..a8ac3c23578 100644 --- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java +++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java @@ -66,7 +66,6 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IO; -import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; @@ -1273,9 +1272,6 @@ public class HttpClientStreamTest extends AbstractTest @ArgumentsSource(TransportProvider.class) public void testClientDefersContentServerIdleTimeout(Transport transport) throws Exception { - // TODO: fix FCGI that is failing this test. - Assumptions.assumeTrue(transport != Transport.FCGI); - init(transport); CountDownLatch dataLatch = new CountDownLatch(1); CountDownLatch errorLatch = new CountDownLatch(1);