Skip to content

Keep frames whole when a send or receive is interrupted, on Windows too - #3

Merged
thomasjm merged 11 commits into
masterfrom
send-survives-interrupt-windows
Dec 4, 2026
Merged

thomasjm merged 11 commits into
masterfrom
send-survives-interrupt-windows

Conversation

@thomasjm

@thomasjm thomasjm commented Dec 3, 2026 •

Copy link
Copy Markdown

Everything in #1, plus what checking it on Windows turned up. Replaces #1 and #2, which were merged without review and have been taken back off master.

  • With WinIO, a receive interrupted by an async exception could take bytes off the socket and then drop them: GHC cancels the overlapped recv and rethrows, discarding a completion that already carried data. makeSocketStream on Windows now runs each receive on its own thread, and an interrupted one leaves its result to the next.
  • CI runs on GHC 9.6 through 9.14.
  • LambdaCase and ScopedTypeVariables are on by default, code the tests share is in a TestLib tree, and imports the Prelude covers are gone.

The receive change is Windows-only; Linux behaviour is unchanged.

Windows results

GHC 9.14 cross-built for x86_64-w64-mingw32 in codedown's toolchain (its WinIO patches to GHC and network 3.2.99.0), run on Windows 11. Interrupt, Server and Warp groups, ten runs each:

WinIO (--io-manager=native) MIO (--io-manager=posix)
Interrupt 10/10 10/10
Server 10/10 10/10
Warp 10/10 0/10

Before the receive fix, interrupted receive failed 4 of 20 runs under WinIO with ParseException "Unknown opcode: 12", and passed 30 of 30 after.

  • WinIO: a send blocked on a stalled peer can be killed, since it waits on an overlapped request rather than inside a foreign call. Stream.close returns promptly and the stalled-client tests pass.
  • MIO: a blocked send is a foreign call killThread can't interrupt, so Stream.close waits on it. abandon a stalled client and warp times out a stalled send in the Warp group fail with warp's handler never finished. Not fixed here. Stock GHC 9.8 with network-3.2.16.0 (this repo's Windows CI job, default I/O manager) passes these two, so this is particular to the toolchain above.

The full suite otherwise fails only RFC 6455, 5.5: Frame decoder shall fail if control frame payload length > 125 bytes, on an error message that doesn't match, as on Linux and master.

@thomasjm
thomasjm force-pushed the send-survives-interrupt-windows branch 5 times, most recently from 010e9bf to 24db798 Compare December 4, 2026 00:36
@thomasjm
thomasjm force-pushed the send-survives-interrupt-windows branch from a94d9c4 to 7a96060 Compare December 4, 2026 08:20
@thomasjm
thomasjm merged commit 08fd269 into master Dec 4, 2026
12 of 14 checks passed
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