Skip to content

fix(http1): park the awaited sender until the coalesce tail is empty (#211) - #212

Merged
EdmondDantes merged 1 commit into
mainfrom
211-awaited-sender-waits-for-tail
Aug 22, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
211-awaited-sender-waits-for-tail

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

Closes #211.

A streamed HTTP/1 response overtook a buffered one still sitting in the coalesce
tail. #209 fixed the two fire-and-forget senders; the awaited ones —
http_connection_send_raw and http_connection_send_strv_awaited — submitted at
conn->io just the same. It takes two buffered responses ahead of the stream to
show it: one in flight, one copied into the tail, and only the tail can be
overtaken, which is why #209's three-request reproduction missed it.

The awaited senders now park until no batched write is outstanding and the tail is
empty, on a connection-lifetime event fired from every site that clears
out_in_flight, a failed submit included. out_signal_drain could not serve: it
fires at the low-water mark and mid-chain, while the flag is still set.

Shape 2 from the issue — append to the tail and return — was refused because it
takes HTTP/1's backpressure with it: h1_stream_append_chunk reads stream_dead
from the send's return value, the write deadline has nothing to bracket, and every
chunk pays back the copy #184 removed. The decision is recorded in the issue.

TLS needs no branch: tls_push takes those bytes before send_raw is reached and
the batched senders are plaintext-only, so the wait condition is unreachable there.
A ZEND_ASSERT says so at the wait.

Cost: an awaited send that lands behind batched bytes now pays a scheduler turn,
and setWriteTimeout bounds the queue wait together with the write.

Evidence: h1/052 — four pipelined requests, /1 and /2 buffered, /3 and /4
streamed. S1,W3a,S2,W3b,W4a,W4b against main, S1,S2,W3a,W3b,W4a,W4b here.
Full suite 461 tests, 436 passed, 0 failed, 24 skipped on absent tool gates, 1 warn
(core/047, the pre-existing XFAIL that passes); ctest 16 of 16.

@github-actions

github-actions Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Total lines: 82.72% → 82.49% (-0.23 pp)

File Baseline Current Δ Touched
src/core/http_connection.c 77.53% 77.02% -0.51 pp ●
src/core/http_connection.h 81.82% 81.82% +0.00 pp ●
src/core/http_connection_tls.c 73.74% 73.46% -0.28 pp
src/http2/http2_session.c 88.76% 85.61% -3.16 pp
src/http3/http3_callbacks.c 83.39% 83.49% +0.11 pp
src/http3/http3_io.c 89.09% 89.45% +0.36 pp
src/http3/http3_listener.c 76.88% 77.93% +1.05 pp
src/http3/http3_static_response.c 76.67% 75.42% -1.25 pp
src/http_body_stream.c 84.85% 75.76% -9.09 pp
src/http_request.c 84.05% 80.96% -3.09 pp
src/websocket/php_websocket.c 78.61% 78.44% -0.17 pp
src/websocket/ws_session.c 90.22% 89.67% -0.55 pp

@EdmondDantes
EdmondDantes force-pushed the 211-awaited-sender-waits-for-tail branch from be530a0 to aa7638e Compare August 22, 2026 07:14
@EdmondDantes
EdmondDantes merged commit 4a7fedb into main Aug 22, 2026
8 checks passed
@EdmondDantes
EdmondDantes deleted the 211-awaited-sender-waits-for-tail branch August 22, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A streamed HTTP/1 response overtakes a buffered one still in the coalesce tail

1 participant