fix(h1): ending close-delimited body should close #2322
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR #2264 introduced a bug where calling
end_body
on close-delimitedencoders would not actually close the connection. This is because the
call to
encoder.end()
now returnsOk(None)
for close-delimitedencoders, to prevent the error from being propagated as though the user
body ended too early. However, when
Ok
is returned, the write state isonly advanced to
Closed
if the encoder returnstrue
fromis_last
.This means that when the body is close-delimited, ending the body does
nothing, leaving the connection in keepalive.
This causes a hang in Linkerd, where we proxy HTTP requests connections
by returning a client body in a response. If the upstream server closes
the connection, we need to rely on the close always being propagated to
the connection with our client. This bug resulted in the body closing
abruptly leaving the connection in a stuck state, instead.
This branch fixes this by special-casing close-delimited bodies so that
they will also set the write state to
Closed
when callingend_body
,even if the
is_last
bit has not been set.Signed-off-by: Eliza Weisman [email protected]