You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A queued plaintext write has no deadline, so a peer that stops reading holds the connection forever #223
http_write_timer_arm has three callers: the two awaited senders
(src/core/http_connection.c:1376, :1465) and http1_stream.c:335 through http_connection_arm_write_deadline, which #179 added for exactly this reason —
"queued bytes carry no await to time out".
The batched senders arm nothing. http_connection_send_batched, http_connection_send_zstr_batched and http_connection_send_batched_writev
submit and return; http_send_batched_finish only ever stops the timer.
Every plaintext HTTP/2 response goes out that way (h2_emit_flush_h2c), and
since #209 and #211 so do the HTTP/1 fire-and-forget senders.
http_connection.h:511-512 already names the hazard in words: "a write to a
peer that stopped reading never completes, and the destroy that defers on out_in_flight never runs."
What follows
A peer that stops reading without closing wedges the writev. out_in_flight
stays true, and:
http_connection_destroy defers at src/core/http_connection.c:360;
the deadline sweep (src/http_server_class.c:862) calls http_connection_destroy on every tick and it re-defers each time, so the
connection, its io and its read buffer are never reclaimed;
One wedged peer per held connection, with no upper bound.
Fix
Arm the connection's write deadline at submit in the batched senders, the way http1_stream.c:335 does for the queued tryWrite() path. The timer is already
stopped by http_send_batched_finish when the chain ends.
This changes HTTP/1 as well as HTTP/2 — a batched response to a peer that stops
reading is now bounded by setWriteTimeout (30 s by default) — so it wants its
own test rather than riding along with #219.
Activity
Merge pull request #228 from true-async/223-outbound-write-deadline