Repository navigation
fix: keep polling after a reactor wait fails - #426
Conversation
|
Warning Review limit reachedThis review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry. Next included review available in 7 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
An automated preview of the documentation is available at https://426.corosio.prtest3.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-11-19 20:54:08 UTC |
|
GCOVR code coverage report https://426.corosio.prtest3.cppalliance.org/gcovr/index.html Build time: 2026-11-19 21:10:30 UTC |
Benchmark report
linux — full results (226 benchmarks, 5 iterations, 1.5s each)accept_churn
fan_out
http_server
local_socket_latency
local_socket_throughput
socket_latency
socket_throughput
windows — full results (77 benchmarks, 5 iterations, 1.5s each)accept_churn
fan_out
http_server
socket_latency
socket_throughput
macos — full results (113 benchmarks, 5 iterations, 1.5s each)accept_churn
fan_out
http_server
local_socket_latency
local_socket_throughput
socket_latency
socket_throughput
Run & raw JSON artifacts · flag rule: |median Δ| > max(2%, 3×CV of the noisier side) · advisory only |
979f37a to
d4b8b0e
Compare
When the reactor's wait call failed, run() rethrew without putting the reactor sentinel back in the queue. The context then never polled for I/O again, and a peer thread parked behind that pass slept forever. The failed pass now requeues the sentinel and wakes every parked thread before the exception leaves run().
A failed timerfd update cleared the stale flag first, so no later pass reprogrammed the timerfd and the next wait could block with a timer due. A failed update after the wait also dropped the events the wait had collected; each was already marked enqueued, so its socket never queued again. The update now leaves the flag set when it fails, and the collected events move to the thread's private queue before anything can throw.
d4b8b0e to
d4bb81c
Compare
When the reactor's wait call failed (
epoll_wait,selectorkeventwith an error other thanEINTR),run()rethrew without putting the reactor sentinel back in the queue. Nothing else pushes it, so the context never polled for I/O again: every laterrun(),run_for()orpoll()ran posted handlers only, and parked reads, writes and accepts never completed. In a multi-threaded loop, a peer thread waiting behind the failed pass also slept forever, since nothing woke it.The failed pass now re-takes the lock if
run_taskreleased it, requeues the sentinel and wakes every waiting thread before the exception leavesrun(). The uring scheduler already does the same.epoll's
run_taskhad two more throw sites with the same effect. A failed timerfd update cleared the stale flag first, so no later pass rearmed the timer and the next wait could block with a timer due. A failed update after the wait dropped the events that wait collected; each was already marked enqueued, so its socket never queued again. The update now leaves the flag set when it fails, and collected events move to the thread's private queue before anything can throw.Descriptors retired during the failed pass stay on the retired list and are settled by the next pass or by
shutdown_drain, so nothing leaks.Tests, in the reactor fault suite (epoll, select, kqueue):
testWaitFailureKeepsPolling: the wait fails andrun()throws; a read parked before the failure must complete on the next run.testWaitFailureLeavesPeerPolling: two threads run the context. A short timer holds the first wait while the second thread parks, the next wait then fails on one thread, and the byte is sent only after the failure, so the surviving thread must be woken to finish the read.In the epoll fault suite:
testRunLoopFaults: a timerfd update that fails before the wait no longer loses the timer; the next run's delay completes.testTimerUpdateFailureKeepsEvents: a byte and a due timer are collected by the same pass, the timer update after the wait fails, and the parked read must still complete on the next run.On kqueue the wakeup also calls
kevent, so the tests fail the wait through a newkevent_waitfault arm that matches only calls collecting events without submitting changes.select retries
EBADF, so its tests fail the wait withEINVAL. Both tests failed on epoll and select before the fix. With the wake removed, the two-thread test fails in 39 of 40 runs, and each epoll test fails with its fix reverted; none failed in hundreds of runs with the fixes in place.Summary by CodeRabbit