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
HTTP/2 over TLS: the hybrid emit alternates two drain cursors over one session #224
http2_session_emit picks the TLS emit mode per pass
(src/http2/http2_strategy.c:1525-1537): H2_EMIT_HYBRID takes the DRAIN path
when session->large_streams_pending == 0 and the GATHER path otherwise. The two
drive nghttp2 through different APIs on the same session:
http2_session_drain parks the tail of a slice it could not fit in session->send_pending / send_pending_offset
(src/http2/http2_session.c:1440-1442, :1460-1462), and resumes from there on
its next call. nghttp2_session_send knows nothing about that field.
nghttp2 states the rule in nghttp2.h: the pointer nghttp2_session_mem_send
assigns is valid until the next call of nghttp2_session_mem_send()or nghttp2_session_send(), and the caller must send all of it before the next
chunk.
The DRAIN buffer is 16649 bytes, so a 16 KiB DATA frame plus its header does not
fit whole and a partial send_pending is the normal case, not the edge one. large_streams_pending crossing zero between two passes is what switches modes.
What follows
The bytes parked in send_pending are never emitted: the GATHER pass resumes
from the next frame. The peer receives a truncated frame followed by a
well-formed frame header — the same shape #219 removed from the plaintext read
path.
Fix
One cursor per session. Either give the TLS DRAIN path a buffer it can always
finish from, or make the mode sticky for the life of a session, or route both
through nghttp2_session_send. Which one depends on why HYBRID exists, which is
a measurement question — the enum's own comment says GATHER is there for large
streams.
Found while reviewing #219 (PR 220). Not reproduced: it needs a TLS session
whose large_streams_pending crosses zero between two emit passes with a
partial slice parked.
Fixed in 18f51b2: a parked slice pins the emit mode — http2_session_has_pending_send(session) is the first term of the DRAIN test (src/http2/http2_strategy.c:1558), so GATHER cannot step past bytes DRAIN left in send_pending. Still owed a test; the CHANGELOG entry says so, and the fault-injection hook it needs has a home in HTTP_SERVER_TEST_HOOKS.
Activity
Merge pull request #228 from true-async/223-outbound-write-deadline
EdmondDantes commentedon Aug 23, 2026
Fixed in 18f51b2: a parked slice pins the emit mode —
http2_session_has_pending_send(session)is the first term of the DRAIN test (src/http2/http2_strategy.c:1558), so GATHER cannot step past bytes DRAIN left insend_pending. Still owed a test; the CHANGELOG entry says so, and the fault-injection hook it needs has a home inHTTP_SERVER_TEST_HOOKS.Merge pull request #252 from true-async/224-emit-mode-selector-test