authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-15 14:09:25-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-29 06:20:49-07:00
log81b1bfbfbbf4f71bc79191ca36ac62c00c8ac92c
tree6a8d5a66256a3aa7d857ca91ce8640f2b87a8741
parent060fd975d95d4472f98bb2c7760afb111d162580

std.Io.Threaded: wrangle TODOs


2 files changed, 6 insertions(+), 29 deletions(-)

BRANCH_TODO deleted-21
......@@ -1,21 +0,0 @@
1* Threaded: finish linux impl (all tests passing)
2* Threaded: finish macos impl
3* Threaded: finish windows impl
4* Threaded: glibc impl of netLookup
5
6* eliminate dependency on std.Thread (Mutex, Condition, maybe more)
7* implement cancelRequest for non-linux posix
8* finish converting all Threaded into directly calling system functions and handling EINTR
9* audit the TODOs
10
11* move max_iovecs_len to std.Io
12* address the cancelation race condition (signal received between checkCancel and syscall)
13* update signal values to be an enum
14* delete the deprecated fs.File functions
15* move fs.File.Writer to Io
16* add non-blocking flag to net and fs operations, handle EAGAIN
17* finish moving std.fs to Io
18* migrate child process into std.Io
19* eliminate std.Io.poll (it should be replaced by "select" functionality)
20* finish moving all of std.posix into Threaded
21* TCP fastopen - sends initial payload along with connection. can be done for idempotent http requests
lib/std/Io/Threaded.zig+6-8
......@@ -133,7 +133,6 @@ fn worker(t: *Threaded) void {
133133 closure.start(closure);
134134 t.mutex.lock();
135135 if (is_concurrent) {
136 // TODO also pop thread and join sometimes
137136 t.concurrent_count -= 1;
138137 }
139138 }
......@@ -1175,7 +1174,7 @@ fn dirCreateFilePosix(
11751174 fl_flags &= ~@as(usize, 1 << @bitOffsetOf(posix.O, "NONBLOCK"));
11761175 while (true) {
11771176 try t.checkCancel();
1178 switch (posix.errno(posix.fcntl(fd, posix.F.SETFL, fl_flags))) {
1177 switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFL, fl_flags))) {
11791178 .SUCCESS => break,
11801179 .INTR => continue,
11811180 else => |err| return posix.unexpectedErrno(err),
......@@ -1304,7 +1303,7 @@ fn dirOpenFile(
13041303 fl_flags &= ~@as(usize, 1 << @bitOffsetOf(posix.O, "NONBLOCK"));
13051304 while (true) {
13061305 try t.checkCancel();
1307 switch (posix.errno(posix.fcntl(fd, posix.F.SETFL, fl_flags))) {
1306 switch (posix.errno(posix.system.fcntl(fd, posix.F.SETFL, fl_flags))) {
13081307 .SUCCESS => break,
13091308 .INTR => continue,
13101309 else => |err| return posix.unexpectedErrno(err),
......@@ -2263,7 +2262,6 @@ fn netSendOne(
22632262 .WSAEDESTADDRREQ => unreachable, // A destination address is required.
22642263 .WSAEFAULT => unreachable, // The lpBuffers, lpTo, lpOverlapped, lpNumberOfBytesSent, or lpCompletionRoutine parameters are not part of the user address space, or the lpTo parameter is too small.
22652264 .WSAEHOSTUNREACH => return error.NetworkUnreachable,
2266 // TODO: WSAEINPROGRESS, WSAEINTR
22672265 .WSAEINVAL => unreachable,
22682266 .WSAENETDOWN => return error.NetworkDown,
22692267 .WSAENETRESET => return error.ConnectionResetByPeer,
......@@ -3186,11 +3184,11 @@ fn lookupDns(
31863184
31873185 for (answers) |answer| {
31883186 var it = HostName.DnsResponse.init(answer) catch {
3189 // TODO accept a diagnostics struct and append warnings
3187 // Here we could potentially add diagnostics to the results queue.
31903188 continue;
31913189 };
31923190 while (it.next() catch {
3193 // TODO accept a diagnostics struct and append warnings
3191 // Here we could potentially add diagnostics to the results queue.
31943192 continue;
31953193 }) |record| switch (record.rr) {
31963194 std.posix.RR.A => {
......@@ -3239,7 +3237,7 @@ fn lookupHosts(
32393237 error.Canceled => |e| return e,
32403238
32413239 else => {
3242 // TODO populate optional diagnostic struct
3240 // Here we could add more detailed diagnostics to the results queue.
32433241 return error.DetectingNetworkConfigurationFailed;
32443242 },
32453243 };
......@@ -3251,7 +3249,7 @@ fn lookupHosts(
32513249 error.ReadFailed => switch (file_reader.err.?) {
32523250 error.Canceled => |e| return e,
32533251 else => {
3254 // TODO populate optional diagnostic struct
3252 // Here we could add more detailed diagnostics to the results queue.
32553253 return error.DetectingNetworkConfigurationFailed;
32563254 },
32573255 },