Open
Conversation
17a28d6 to
84f1b1d
Compare
Another attempt at haskell#364, haskell#509, haskell#602 with the following design choices: 1. On Windows systems, `Socket` becomes an `Either` over the existing "Posix" socket implemntation and a Windows equivalent using its `SOCKET` type. 2. On Posix systems, or without enabling the WinIO manager with `--io-manager=native`, the current behavior is unchanged. 3. *With* the WinIO manager, a greenfield implementation around the relevant syscalls is used, using IO Completion Ports (AKA "Overlapped IO") through GHC's `withOverlapped` For the places we need to mux between the two (`Network.Socket.Syscall`, `Network.Socket.Buffer`, etc.) the existing implementation is moved into a `Posix.hsc` and the WinIO one is defined in `WinIO.hsc`. There's certainly some cleanup and style improvements that could be done, but it passes all existing tests, and hopefully provides a clean separation between the existing code (which can stay unchanged) and direct use of Windows syscalls through `withOverlapped`.
mrkline
commented
Apr 5, 2026
Comment on lines
+90
to
+95
| -- On Windows with the WinIO (IOCP) I/O manager, GHC's withOverlappedEx | ||
| -- converts async exceptions (including the one thrown by timeout) into a | ||
| -- synchronous IOException via `throwWinErr ... 0` | ||
| -- ("The operation completed successfully"). | ||
| -- `timeout` does not recognise this IOException as | ||
| -- its own exception, so it escapes. |
Author
There was a problem hiding this comment.
This is probably something worth discussing with GHC folks - the WinIO withOverlapped code eats async exceptions and turns them into IOExceptions, which breaks the assumptions of timeout and others I'm sure.
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.
Another attempt at #364, #509, #602 with the following design choices:
On Windows systems,
Socketbecomes anEitherover the existing "Posix" socket implemntation and a Windows equivalent using itsSOCKETtype.On Posix systems, or without enabling the WinIO manager with
--io-manager=native, the current behavior is unchanged.With the WinIO manager, a greenfield implementation around the relevant syscalls is used, using IO Completion Ports (AKA "Overlapped IO") through GHC's
withOverlappedFor the places we need to mux between the two
(
Network.Socket.Syscall,Network.Socket.Buffer, etc.) the existing implementation is moved into aPosix.hscand the WinIO one is defined inWinIO.hsc.There's certainly some cleanup and style improvements that could be done, but it passes all existing tests, and hopefully provides a clean separation between the existing code (which can stay unchanged) and direct use of Windows syscalls through
withOverlapped.