Skip to content

fix(io_uring): balance io_uring_inflight_ in drain_cqes_for (#299)#308

Merged
mvandeberg merged 1 commit into
cppalliance:develop-2from
mvandeberg:pr/299-drain-cqes-inflight
Jul 7, 2026
Merged

fix(io_uring): balance io_uring_inflight_ in drain_cqes_for (#299)#308
mvandeberg merged 1 commit into
cppalliance:develop-2from
mvandeberg:pr/299-drain-cqes-inflight

Conversation

@mvandeberg

Copy link
Copy Markdown
Contributor

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).

…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).
@cppalliance-bot

Copy link
Copy Markdown

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

@mvandeberg mvandeberg merged commit 7532b87 into cppalliance:develop-2 Jul 7, 2026
38 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Beast2 Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants