Skip to content

Commit

Permalink
Add ability to control server backlog.
Browse files Browse the repository at this point in the history
Also fixes IncompletePostTestCase which has backlog issues on windows.

Fixes quarkusio#23642
  • Loading branch information
stuartwdouglas committed Feb 14, 2022
1 parent 9617345 commit e39a0e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
Expand All @@ -18,13 +16,13 @@
import io.restassured.config.HttpClientConfig;
import io.restassured.config.RestAssuredConfig;

@DisabledOnOs(value = OS.WINDOWS, disabledReason = "very flaky, see https://github.com/quarkusio/quarkus/issues/23642")
public class IncompletePostTestCase {

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(PostEndpoint.class));
.addClasses(PostEndpoint.class))
.overrideConfigKey("quarkus.http.accept-backlog", "200");

@TestHTTPResource
URL url;
Expand All @@ -34,8 +32,8 @@ public void testIncompleteWrite() throws Exception {
PostEndpoint.invoked = false;

//make sure incomplete writes do not block threads
//and that incoplete data is not delivered to the endpoint
for (int i = 0; i < 1000; ++i) {
//and that incomplete data is not delivered to the endpoint
for (int i = 0; i < 100; ++i) {
Socket socket = new Socket(url.getHost(), url.getPort());
socket.getOutputStream().write(
"POST /post HTTP/1.1\r\nHost: localhost\r\nContent-length:10\r\n\r\ntest".getBytes(StandardCharsets.UTF_8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ public class HttpConfiguration {
@ConfigItem
public boolean tcpFastOpen;

/**
* The accept backlog, this is how many connections can be waiting to be accepted before connections start being rejected
*/
@ConfigItem
public int acceptBacklog;

/**
* Path to a unix domain socket
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ private static HttpServerOptions createHttpServerOptions(HttpConfiguration httpC
options.setReusePort(httpConfiguration.soReusePort);
options.setTcpQuickAck(httpConfiguration.tcpQuickAck);
options.setTcpCork(httpConfiguration.tcpCork);
options.setAcceptBacklog(httpConfiguration.acceptBacklog);
options.setTcpFastOpen(httpConfiguration.tcpFastOpen);
options.setCompressionSupported(httpConfiguration.enableCompression);
options.setDecompressionSupported(httpConfiguration.enableDecompression);
Expand Down

0 comments on commit e39a0e8

Please sign in to comment.