fix(io_uring): balance io_uring_inflight_ in drain_cqes_for (#299)#308
Merged
mvandeberg merged 1 commit intoJul 7, 2026
Merged
Conversation
…nce#299) drain_cqes_for advanced CQEs via io_uring_cq_advance without decrementing io_uring_inflight_, unlike process_completions. Every CQE it swallowed during an acceptor teardown — the multishot accept's terminal CQE, the self-submitted cancel SQE, and any sibling ops' CQEs — leaked its count, so the counter drifted upward and permanently defeated the do_one idle-skip ring-pump optimisation for the lifetime of the io_context. Mirror process_completions' accounting in the drain loop: classify each CQE and decrement only on non-F_MORE op/cancel CQEs. The wakeup-eventfd and signal self-pipe CQEs are never counted, so they are never decremented; both re-arm their multishot poll on a terminal CQE (the eventfd byte is also drained). Without the signal-pipe branch a terminal signal CQE would be wrongly decremented (driving the counter negative) and its poll left un-armed. Add a test-only inflight() accessor and a regression test that asserts the counter returns to zero after a listening acceptor is destroyed; without the fix it leaks (observed: 3).
|
An automated preview of the documentation is available at https://308.corosio.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-07-06 22:09:06 UTC |
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.
drain_cqes_for advanced CQEs via io_uring_cq_advance without decrementing io_uring_inflight_, unlike process_completions. Every CQE it swallowed during an acceptor teardown — the multishot accept's terminal CQE, the self-submitted cancel SQE, and any sibling ops' CQEs — leaked its count, so the counter drifted upward and permanently defeated the do_one idle-skip ring-pump optimisation for the lifetime of the io_context.
Mirror process_completions' accounting in the drain loop: classify each CQE and decrement only on non-F_MORE op/cancel CQEs. The wakeup-eventfd and signal self-pipe CQEs are never counted, so they are never decremented; both re-arm their multishot poll on a terminal CQE (the eventfd byte is also drained). Without the signal-pipe branch a terminal signal CQE would be wrongly decremented (driving the counter negative) and its poll left un-armed.
Add a test-only inflight() accessor and a regression test that asserts the counter returns to zero after a listening acceptor is destroyed; without the fix it leaks (observed: 3).