Repository navigation
fix(http1): queue an owned-buffer response behind the write in flight (#209) - #210
Merged
Merged
Conversation
Contributor
CoverageTotal lines: 82.62% → 82.54% (-0.07 pp)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #209. Carries the plan correction that PR 208 held, now that writing the
reproduction turned its open item into a defect.
Three pipelined requests on one plaintext HTTP/1 connection, answered with 2, 2
and 1800 bytes, came back in the order 1, 3, 2 — three runs out of three. A
pipelined client matches responses to requests by order (RFC 9112 §9.3.1), so it
read response 3's body as the answer to request 2.
Cause
The dispose picks its sender by body size. Under
HTTP_WRITEV_THRESHOLDit useshttp_connection_send_zstr_batched, which honours the connection's writeordering: one write in flight, everything behind it in
conn->out_pending_buf,drained by the completion callback. At or over the threshold it used
http_connection_send_strv_owned, which submittedZEND_ASYNC_IO_WRITEVstraight at
conn->io— reading neitherout_in_flightnor setting it.So response 1 went in flight, response 2 into the tail, and response 3 past both.
Fix
Both owned-buffer senders now submit through
http_connection_send_batched_writev,which already implements that discipline for an iov with a free callback. The
slots travel as its user data and are released once, wherever the write ends.
http_connection_send_str_ownedbecomes the one-slot case, and the callback thatreleased a single body is gone with it.
http_connection_emit_parse_errorstill bypasses the tail with a directsend(2)and stays that way: it retires the connection in the same breath, and the bypass
is documented against a race with the close. Named in the issue, not changed.
What the plan correction says
The two remaining HTTP/1 outbound steps rested on "that number has never been
taken". It was taken on 2026-08-20 and is in
dev/BENCHMARKS.md, the change itsupported has landed, and it explicitly does not support the queue design. #179 is
left with one thing to argue on its own: a non-blocking
tryWrite()on HTTP/1.Evidence
h1/049pipelines small, small, large on one connection and reads the bodiesback. Against
main:Local run: 459 phpt, 434 passed, 0 failed, 24 skipped on absent tool gates, 1 warn
(
core/047, the pre-existing XFAIL that passes).ctest16 of 16.