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 fd3657bf8c.

closes #31011
reopens #30865
This commit is contained in:
Andrew Kelley
2026-01-26 14:11:45 -08:00
parent 5eb55ba866
commit 1b235540c1
+5 -1
View File
@@ -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);