Skip to content

acceptWith: keep to the give-up when another waiter takes the connection (v3.2) - #663

Merged
kazu-yamamoto merged 2 commits into
haskell:v3.2from
kazu-yamamoto:accept-with-giveup-3.2
Nov 22, 2026
Merged

kazu-yamamoto merged 2 commits into
haskell:v3.2from
kazu-yamamoto:accept-with-giveup-3.2

Conversation

@kazu-yamamoto

Copy link
Copy Markdown
Collaborator

Backport of #662 to v3.2.

  • On POSIX, acceptWith now tries a non-blocking accept (the internal acceptNoWait) once the socket is readable. If another waiter took the connection, it waits again under the give-up instead of blocking in accept.
  • On Windows, v3.2 cancels the accept on a give-up, so a thread which loses the race already returns. The code is unchanged there, and the new test passes.
  • New test: two threads in acceptWith on one listener, one connection. The thread which loses must return Left once its give-up fires. It fails before the fix on POSIX.
  • Tested on macOS, Rocky Linux, and Windows with GHC 9.12.5-rc4 and 9.8.2 (No IO Manager). On Windows, the three ICMP unreachable tests fail as before; master retries them (Retry ICMP unreachable tests on Windows, pending if none comes #652).

A second commit silences warnings which appear only on Windows.

🤖 Generated with Claude Code

kazu-yamamoto and others added 2 commits November 22, 2026 13:03
All the waiters on a listening socket wake for one connection.  On
POSIX, the others met EAGAIN inside accept and waited there, out of
reach of the give-up.  Now acceptWith tries a non-blocking accept once
and, if the connection is gone, waits again under the give-up.  On
Windows the accept is cancelled on a give-up, so nothing changes there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kazu-yamamoto
kazu-yamamoto merged commit 920372c into haskell:v3.2 Nov 22, 2026
19 checks passed
@kazu-yamamoto
kazu-yamamoto deleted the accept-with-giveup-3.2 branch November 22, 2026 04:24
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.

1 participant