Repository navigation
Mark the handle failed when a stream write is refused at submit - #315
Merged
Merged
Conversation
EdmondDantes
added a commit
to true-async/php-src
that referenced
this pull request
Oct 9, 2026
asynctest: a stream write refused at submit marks the handle failed (true-async/php-async#315)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
A fire-and-forget write's completion carries no status, so its
free_cbreads the verdict fromZEND_ASYNC_IO_WRITE_FAILEDon the handle. A refused submit reaches thatfree_cbfrom inside the submit call, through the request's dispose, and every refusal left the flag clear: a writeuv_writerefused at once, one over the 0x7ffff000-byte cap or the platform's buffer limit, and a vectored write with more than 65535 slots, unsupported flags or on a closed or non-stream handle. true-async-server read each of them as a write that went out and counted it intls_bytes_ciphertext_out_total. Every refusal now sets the flag before the buffer is handed back.A write on a closed handle returned NULL and never handed its buffer back, while
writevon one did, so a fire-and-forget caller leaked it. It now goes throughfree_cbas on every other refusal. The server never writes to an io it has closed: its destroy clearsconn->iobefore the close.Part of true-async/server#396 (stage S4.1 in its
dev/PLAN.md). Reviewed on the diff by a Critic twice; the second pass found nothing blocking.Evidence:
sapi/asynctest/tests/test_write_refused.c(true-async/php-src, branchasynctest/refused-write-verdict): 7 of 8 cases fail onmain(c95dcf7), 8 of 8 pass here, 3 runs. The eighth is the control: a write that succeeds leaves the flag clear. Without the two flags at theuv_writeerrors, the two cases that write to a read-only pipe fail.Not in this PR, recorded in the server plan (items 41, 42): a file write whose dispatch fails, and the Windows synchronous stream path, still never call
free_cb; refusals throw beforefree_cbruns; no CI job runs the asynctest SAPI.