From 915a2f8a07d5f07197955d4a99edaede1a089c92 Mon Sep 17 00:00:00 2001 From: Jay Leaton <58495321+jayleaton@users.noreply.github.com> Date: Wed, 21 Oct 2026 02:50:29 +0700 Subject: [PATCH] Windows: digest keys and the speech stream's socket options build on Windows hosts Main's zig-windows job fails in these two files for every pull request based on it: - digest_key's portable fallback reads Windows' signed 64-bit inode as u64; Linux and macOS return from their own statx / fstat branches above it. - speech.zig sets TCP_NODELAY through sys.posix on Windows, where the socket is a Winsock handle; POSIX keeps its std.c.setsockopt. The send stall uses sys.posix, which is std.posix off Windows. Carried unchanged from #1034's two files. --- zig/src/core/digest_key.zig | 2 +- zig/src/server/speech.zig | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/zig/src/core/digest_key.zig b/zig/src/core/digest_key.zig index 966f1fd223..e3682575ee 100644 --- a/zig/src/core/digest_key.zig +++ b/zig/src/core/digest_key.zig @@ -31,7 +31,7 @@ pub const Key = struct { } const s = try file.stat(io); if (s.kind != .file) return error.DigestNotRegular; - return .{ .device = 0, .inode = s.inode, .size = s.size, .mtime = s.mtime.toNanoseconds(), .ctime = s.ctime.toNanoseconds() }; + return .{ .device = 0, .inode = @as(u64, @bitCast(s.inode)), .size = s.size, .mtime = s.mtime.toNanoseconds(), .ctime = s.ctime.toNanoseconds() }; } pub fn equal(a: Key, b: Key) bool { diff --git a/zig/src/server/speech.zig b/zig/src/server/speech.zig index ec6166bed9..b7f474facd 100644 --- a/zig/src/server/speech.zig +++ b/zig/src/server/speech.zig @@ -1,5 +1,6 @@ //! POST /v1/audio/speech: WAV or raw PCM whole, or raw PCM chunks with stream; only complete synthesis is audio. const std = @import("std"); +const platform = @import("sys"); const api = @import("engine_api"); const json = @import("json"); const errors = @import("errors.zig"); @@ -276,10 +277,10 @@ fn startStream(c: *Conn, sample_rate: u32) error{Closed}!void { if (c.close) c.addHeader("Connection", "close") catch return error.Closed; // each chunk leaves at once rather than waiting on the client's acknowledgement of the last (no effect off TCP) const one: c_int = 1; - _ = std.c.setsockopt(c.fd, std.posix.IPPROTO.TCP, std.posix.TCP.NODELAY, &one, @sizeOf(c_int)); + if (platform.windows) platform.posix.setsockopt(c.fd, platform.posix.IPPROTO.TCP, platform.posix.TCP.NODELAY, std.mem.asBytes(&one)) catch {} else _ = std.c.setsockopt(c.fd, std.posix.IPPROTO.TCP, std.posix.TCP.NODELAY, &one, @sizeOf(c_int)); // a blocking write into a full socket returns after the stall limit, so writeAll's poll can end a stalled stream - const stall: std.posix.timeval = .{ .sec = @divTrunc(c.timeouts.write_ms, 1000), .usec = @rem(c.timeouts.write_ms, 1000) * 1000 }; - std.posix.setsockopt(c.fd, std.posix.SOL.SOCKET, std.posix.SO.SNDTIMEO, std.mem.asBytes(&stall)) catch {}; + const stall: platform.posix.timeval = .{ .sec = @divTrunc(c.timeouts.write_ms, 1000), .usec = @rem(c.timeouts.write_ms, 1000) * 1000 }; + platform.posix.setsockopt(c.fd, platform.posix.SOL.SOCKET, platform.posix.SO.SNDTIMEO, std.mem.asBytes(&stall)) catch {}; return c.finish(""); }