From 1b235540c1d1acdd59aee3c2a8756bc7f0fa55a3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 26 Jan 2026 14:11:45 -0800 Subject: [PATCH] Revert "Io.Threaded: remove WSA_FLAG_OVERLAPPED from socket call" The stated reason for this commit was cancelation didn't work. On further review, we know why cancelation didn't work, and recent enhancements on master branch make it easy to make it work. Meanwhile, not using overlapped means that multiple threads cannot use the same open socket handle. I also added line comments to explain the choice in this revert commit. This reverts commit fd3657bf8c3a2861e1b35cf36d469d342d853880. closes #31011 reopens #30865 --- lib/std/Io/Threaded.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/std/Io/Threaded.zig b/lib/std/Io/Threaded.zig index 4d5073f659..38f6199f46 100644 --- a/lib/std/Io/Threaded.zig +++ b/lib/std/Io/Threaded.zig @@ -11025,7 +11025,11 @@ fn openSocketWsa( ) !ws2_32.SOCKET { const mode = posixSocketMode(options.mode); const protocol = posixProtocol(options.protocol); - const flags: u32 = ws2_32.WSA_FLAG_NO_HANDLE_INHERIT; + // WSA_FLAG_OVERLAPPED is chosen here because without this different + // threads cannot use the same open socket handle. + // TODO: the below code needs to use the AlertableSyscall mechanism instead in + // order to make cancelation work. + const flags: u32 = ws2_32.WSA_FLAG_OVERLAPPED | ws2_32.WSA_FLAG_NO_HANDLE_INHERIT; var syscall: Syscall = try .start(); while (true) { const rc = ws2_32.WSASocketW(family, @bitCast(mode), @bitCast(protocol), null, 0, flags);