Skip to content

fix: handle ECONNRESET from sysread on Windows#33

Merged
toddr merged 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-issue-26
Mar 21, 2026
Merged

fix: handle ECONNRESET from sysread on Windows#33
toddr merged 1 commit intocpan-authors:mainfrom
toddr-bot:koan.toddr.bot/fix-issue-26

Conversation

@toddr-bot
Copy link
Collaborator

@toddr-bot toddr-bot commented Mar 21, 2026

Summary

On Windows, Perl emulates socketpair(PF_UNIX) via TCP localhost sockets. When the remote end calls close() without shutdown(), a TCP RST is sent instead of FIN, causing sysread() to fail with ECONNRESET rather than returning 0 for EOF. This makes ready() report a read error instead of treating it as a normal disconnect.

This fix treats ECONNRESET the same as ESPIPE (the Solaris EOF equivalent) — both indicate the remote end has disconnected, not a true read error.

Fixes #26

Changes

  • Add $!{ECONNRESET} check alongside existing $!{ESPIPE} in ready()'s sysread error handling
  • Add test for abrupt close (close without shutdown) to verify graceful handling

Test plan

  • New subtest "end-to-end: ERROR response with abrupt close" verifies that ready() handles abrupt disconnects gracefully
  • On Unix, the response arrives before EOF so the parse succeeds; on Windows, if RST races with data, the error is handled gracefully instead of dying
  • Full test suite shows no regressions (pre-existing platform-specific failures unchanged)

Generated by Kōan /fix


Quality Report

Changes: 2 files changed, 41 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

On Windows, Perl emulates socketpair(PF_UNIX) via TCP localhost
sockets.  When the remote end calls close() without shutdown(),
a TCP RST is sent instead of FIN, causing sysread() to fail with
ECONNRESET ("An existing connection was forcibly closed by the
remote host") rather than returning 0 for EOF.

Treat ECONNRESET the same as ESPIPE (Solaris EOF) — both indicate
the remote end has disconnected, not a true read error.

Fixes cpan-authors#26

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@toddr toddr marked this pull request as ready for review March 21, 2026 01:13
@toddr toddr merged commit 5c57ba3 into cpan-authors:main Mar 21, 2026
23 checks passed
toddr-bot added a commit to toddr-bot/Net-Ident that referenced this pull request Mar 22, 2026
cpanfile listed Fcntl and Config which are not used by Ident.pm
(Fcntl was removed when PR cpan-authors#14 replaced fcntl() with blocking(0)).
Errno is used but was missing from both cpanfile and PREREQ_PM.

Also updates Changes with post-1.27 fixes that were merged but
not recorded (PRs cpan-authors#25, cpan-authors#30, cpan-authors#31, cpan-authors#33).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Break on 5.32 MSWin32-x64-multi-thread

2 participants