fix: correct paused-channel count in _select_loop - #284
Draft
toddr-bot wants to merge 1 commit into
Draft
Conversation
When an input channel transitions from paused to closed during the unpausing check, _select_loop previously incremented $paused for the now-closed channel. This overcounting could cause premature loop exit via break_on_io or unnecessary timeout shortening. Only count channels with a defined FD as genuinely paused. Also replace the stale EINTR TODOs (the test already exists as t/eintr.t) with a cross-reference comment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
What
Fix _select_loop's $paused counter to exclude channels that closed during the unpausing check.
Why
The original author acknowledged this bug in a comment (lines 3389-3393): when
_do_filterscloses a channel that was paused, the channel was still counted as paused. This overcounting can cause:break_on_ioexit from pump()The comment says "mostly harmless" because the count self-corrects on the next iteration after
_clobberremoves the closed channel from PIPES. But it's still incorrect and can cause subtle timing issues.How
$pausedwhen$file->{FD}is still defined (i.e., the channel is genuinely paused, not closed)t/eintr.tTesting
t/paused_input_close.t(7 tests): exercises the paused→closed transition with staged callbacks, verifying correct completion and no fd leaks🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 128 insertions(+), 8 deletions(-)
Code scan: clean
Tests: failed (0 Failed, 37 tests)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline