Commit 3174079c authored by Kenton Varda's avatar Kenton Varda

Improve readability of HTTP server timeout handling.

parent 66ce4ca9
...@@ -3294,13 +3294,13 @@ public: ...@@ -3294,13 +3294,13 @@ public:
if (!firstRequest) { if (!firstRequest) {
// For requests after the first, require that the first byte arrive before the pipeline // For requests after the first, require that the first byte arrive before the pipeline
// timeout, otherwise treat it like the connection was simply closed. // timeout, otherwise treat it like the connection was simply closed.
firstByte = firstByte auto timeoutPromise = server.timer.afterDelay(server.settings.pipelineTimeout)
.exclusiveJoin(server.timer.afterDelay(server.settings.pipelineTimeout)
.exclusiveJoin(server.onDrain.addBranch()) .exclusiveJoin(server.onDrain.addBranch())
.then([this]() -> bool { .then([this]() -> bool {
timedOut = true; timedOut = true;
return false; return false;
})); });
firstByte = firstByte.exclusiveJoin(kj::mv(timeoutPromise));
} }
auto receivedHeaders = firstByte auto receivedHeaders = firstByte
...@@ -3328,13 +3328,13 @@ public: ...@@ -3328,13 +3328,13 @@ public:
if (firstRequest) { if (firstRequest) {
// On the first request, the header timeout starts ticking immediately upon request opening. // On the first request, the header timeout starts ticking immediately upon request opening.
receivedHeaders = receivedHeaders auto timeoutPromise = server.timer.afterDelay(server.settings.headerTimeout)
.exclusiveJoin(server.timer.afterDelay(server.settings.headerTimeout)
.exclusiveJoin(server.onDrain.addBranch()) .exclusiveJoin(server.onDrain.addBranch())
.then([this]() -> kj::Maybe<HttpHeaders::Request> { .then([this]() -> kj::Maybe<HttpHeaders::Request> {
timedOut = true; timedOut = true;
return nullptr; return nullptr;
})); });
receivedHeaders = receivedHeaders.exclusiveJoin(kj::mv(timeoutPromise));
} }
return receivedHeaders return receivedHeaders
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment