Repository navigation
Add isWritable() so a handler can tell a slow client from a gone one (#175) - #176
Merged
Merged
Conversation
Contributor
CoverageTotal lines: 82.26% → 82.17% (-0.10 pp)
❌ Regression in touched files (> 1.0 pp drop)
Add |
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 #175. First code step of the response body contract in dev/PLAN.md.
sendable()folds four questions into one bool — closed, sealed, no stream ops, queue full — and only the last is transient, so a streaming loop cannot tell "yield and continue" from "stop".isClosed()does not help: it reports that this code calledend().isWritable()answers the liveness half, and every input is a one-way latch, so a false answer never turns true again. Backed by a new optionalis_aliveop inhttp_response_stream_ops_t; no transport needed new state except HTTP/1.On HTTP/1 a departed peer is only visible when a write fails — TCP offers no earlier signal — so
h1_stream_append_chunknow records that discovery on the request context andis_aliveanswers from it, rather than making the caller find out with a second doomed write. H2 readspeer_closedandwrite_timed_out, H3 the four conditions its append refuses on, the worker path the stream credit.Evidence:
tests/phpt/server/h1/027-h1-is-writable.phpt— the handler asks before the stream, after the commit, and again after catching the 499 from a peer that aborted with SO_LINGER 0; the answer flips exactly once. Suites: h1 + core, 98 passed, 0 failed.