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 {...@@ -133,7 +133,6 @@ fn worker(t: *Threaded) void {
133 closure.start(closure);133 closure.start(closure);
134 t.mutex.lock();134 t.mutex.lock();
135 if (is_concurrent) {135 if (is_concurrent) {
136 // TODO also pop thread and join sometimes
137 t.concurrent_count -= 1;136 t.concurrent_count -= 1;
138 }137 }
139 }138 }
...@@ -1175,7 +1174,7 @@ fn dirCreateFilePosix(...@@ -1175,7 +1174,7 @@ fn dirCreateFilePosix(
1175 fl_flags &= ~@as(usize, 1 << @bitOffsetOf(posix.O, "NONBLOCK"));1174 fl_flags &= ~@as(usize, 1 << @bitOffsetOf(posix.O, "NONBLOCK"));
1176 while (true) {1175 while (true) {
1177 try t.checkCancel();1176 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))) {
1179 .SUCCESS => break,1178 .SUCCESS => break,
1180 .INTR => continue,1179 .INTR => continue,
1181 else => |err| return posix.unexpectedErrno(err),1180 else => |err| return posix.unexpectedErrno(err),
...@@ -1304,7 +1303,7 @@ fn dirOpenFile(...@@ -1304,7 +1303,7 @@ fn dirOpenFile(
1304 fl_flags &= ~@as(usize, 1 << @bitOffsetOf(posix.O, "NONBLOCK"));1303 fl_flags &= ~@as(usize, 1 << @bitOffsetOf(posix.O, "NONBLOCK"));
1305 while (true) {1304 while (true) {
1306 try t.checkCancel();1305 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))) {
1308 .SUCCESS => break,1307 .SUCCESS => break,
1309 .INTR => continue,1308 .INTR => continue,
1310 else => |err| return posix.unexpectedErrno(err),1309 else => |err| return posix.unexpectedErrno(err),
...@@ -2263,7 +2262,6 @@ fn netSendOne(...@@ -2263,7 +2262,6 @@ fn netSendOne(
2263 .WSAEDESTADDRREQ => unreachable, // A destination address is required.2262 .WSAEDESTADDRREQ => unreachable, // A destination address is required.
2264 .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.2263 .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.
2265 .WSAEHOSTUNREACH => return error.NetworkUnreachable,2264 .WSAEHOSTUNREACH => return error.NetworkUnreachable,
2266 // TODO: WSAEINPROGRESS, WSAEINTR
2267 .WSAEINVAL => unreachable,2265 .WSAEINVAL => unreachable,
2268 .WSAENETDOWN => return error.NetworkDown,2266 .WSAENETDOWN => return error.NetworkDown,
2269 .WSAENETRESET => return error.ConnectionResetByPeer,2267 .WSAENETRESET => return error.ConnectionResetByPeer,
...@@ -3186,11 +3184,11 @@ fn lookupDns(...@@ -3186,11 +3184,11 @@ fn lookupDns(
31863184
3187 for (answers) |answer| {3185 for (answers) |answer| {
3188 var it = HostName.DnsResponse.init(answer) catch {3186 var it = HostName.DnsResponse.init(answer) catch {
3189 // TODO accept a diagnostics struct and append warnings3187 // Here we could potentially add diagnostics to the results queue.
3190 continue;3188 continue;
3191 };3189 };
3192 while (it.next() catch {3190 while (it.next() catch {
3193 // TODO accept a diagnostics struct and append warnings3191 // Here we could potentially add diagnostics to the results queue.
3194 continue;3192 continue;
3195 }) |record| switch (record.rr) {3193 }) |record| switch (record.rr) {
3196 std.posix.RR.A => {3194 std.posix.RR.A => {
...@@ -3239,7 +3237,7 @@ fn lookupHosts(...@@ -3239,7 +3237,7 @@ fn lookupHosts(
3239 error.Canceled => |e| return e,3237 error.Canceled => |e| return e,
32403238
3241 else => {3239 else => {
3242 // TODO populate optional diagnostic struct3240 // Here we could add more detailed diagnostics to the results queue.
3243 return error.DetectingNetworkConfigurationFailed;3241 return error.DetectingNetworkConfigurationFailed;
3244 },3242 },
3245 };3243 };
...@@ -3251,7 +3249,7 @@ fn lookupHosts(...@@ -3251,7 +3249,7 @@ fn lookupHosts(
3251 error.ReadFailed => switch (file_reader.err.?) {3249 error.ReadFailed => switch (file_reader.err.?) {
3252 error.Canceled => |e| return e,3250 error.Canceled => |e| return e,
3253 else => {3251 else => {
3254 // TODO populate optional diagnostic struct3252 // Here we could add more detailed diagnostics to the results queue.
3255 return error.DetectingNetworkConfigurationFailed;3253 return error.DetectingNetworkConfigurationFailed;
3256 },3254 },
3257 },3255 },