From cca47d63c3ba774cb4de6f76603ba6edc5b475fe Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 20:46:28 -0300 Subject: fs: a backend can keep a parked request by ticket and answer it later, and a clunk interrupts what is parked on its fid A backend holding a read that has nothing yet had to find its park by walking the engine's slots and matching a tag. Now Conn.hold() answers .again and returns a Ticket (slot and that park's sequence number); Conn.waiting() says whether that very park still waits, and Conn.answerWith() answers it with what a producer makes, asking the producer only while it waits and under the same lock, the way lib9p lets a server keep a Req and respond() later, so a consuming answer is never spent on a flushed request. The sequence number counts on across the connections a runner slot serves (initIn keeps it), so a ticket of one never names a park of the next. A clunk or remove fails everything parked on its fid with EINTR first, so no slot outlives its fid to be retried with a released handle or answered to a fid of the same number walked anew; retry's check for a vanished fid is gone with it. 9ns maps acme's "shut down" to EIO. Co-Authored-By: Claude Opus 5.5 --- 9ns/src/nine.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to '9ns') diff --git a/9ns/src/nine.zig b/9ns/src/nine.zig index 52a45ae..1079a1d 100644 --- a/9ns/src/nine.zig +++ b/9ns/src/nine.zig @@ -911,6 +911,9 @@ pub fn enameToErrno(ename: []const u8) linux.E { // A server that answers a flushed request with an error (Pardes says // "Interrupted system call") should look like a flush to the caller. .{ .needle = "interrupt", .err = .INTR }, + // acme's answer to a read whose window closed under it (Pardes says + // it too): the file is still named, it just has no more to give. + .{ .needle = "shut down", .err = .IO }, .{ .needle = "not exist", .err = .NOENT }, .{ .needle = "not found", .err = .NOENT }, .{ .needle = "no such", .err = .NOENT }, @@ -1035,6 +1038,7 @@ test { test "ename → errno mapping" { try testing.expectEqual(linux.E.INTR, enameToErrno("Interrupted system call")); try testing.expectEqual(linux.E.INTR, enameToErrno("read interrupted")); + try testing.expectEqual(linux.E.IO, enameToErrno("window shut down")); try testing.expectEqual(linux.E.NOENT, enameToErrno("file does not exist")); try testing.expectEqual(linux.E.NOENT, enameToErrno("No Such File")); try testing.expectEqual(linux.E.NOENT, enameToErrno("directory entry not found")); -- cgit v1.3