diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/fs.zig | 23 | ||||
| -rw-r--r-- | core/ninep/tree.zig | 5 | ||||
| -rw-r--r-- | core/replica.zig | 12 |
3 files changed, 33 insertions, 7 deletions
diff --git a/core/fs.zig b/core/fs.zig index dcc33cd6..eadb7c19 100644 --- a/core/fs.zig +++ b/core/fs.zig @@ -843,7 +843,10 @@ pub const EditHold = struct { pub const Namespace = struct { /// What a step reads that 9P requests made (every request an input /// each replica replays) is the core's like any state: the open - /// records and the writes held to go in as one edit, digested and dumped (a client's join takes them from + /// records (a command pane a script reads is not taken again: + /// exec.leased), the panes the last look or exec touched (a new open's + /// own), the writes held to go in as one edit and a header tag's + /// truncation, digested and dumped (a client's join takes them from /// the dump; a session revived from one drops the opens with the /// connections that held them: dump.zig `loadAndRevive`). The rest is /// the server's (core/walk.zig): its sockets and the mounts (dumped @@ -861,9 +864,9 @@ pub const Namespace = struct { "lsp_answer_at", "edit_started", "edit_hold", "edit_said", "lsp_result", "write_room", "write_waits", "log_full_hash", "pages", "closed_lines", "ran_at", "refilled", "failures", "ename", "news", "hanging_up", "log", "plumb_held", - "results", "results_len", "started", "header_rewrite", "header_trunc_pending", "header_held", + "started", }, - .len = .{.{ "opens", "opens_len" }}, + .len = .{ .{ "opens", "opens_len" }, .{ "results", "results_len" } }, }; socket_path: []const u8 = "", tcp_address: ?std.Io.net.IpAddress = null, @@ -1025,11 +1028,17 @@ pub const Namespace = struct { /// Its digest (core/walk.zig): the opens in use, and writes held by /// their length (their bytes are the same writes on every side; a /// stream of 8 KB appends hashed whole cost each its length again; - /// none held, the rest of `batch` is nothing a step reads). Nothing at + /// none held, the rest of `batch` is nothing a step reads), the panes + /// the last look or exec touched, a header's truncation. Nothing at /// all for a session no script holds anything of. pub fn digest(st: *const Namespace, h: *pardes.walk.Hasher) void { - comptime if (pardes.walk.fieldNames(Namespace).len != 3) @compileError("Namespace.digest: hash every field the walk does not leave out"); + comptime if (pardes.walk.fieldNames(Namespace).len != 8) @compileError("Namespace.digest: hash every field the walk does not leave out"); for (st.opens[0..st.opens_len]) |*o| pardes.walk.hash(tree.Open, o, h); + h.update(std.mem.sliceAsBytes(st.results[0..st.results_len])); + if (st.header_rewrite != null or st.header_trunc_pending != null or st.header_held) { + const words = [_]u64{ st.header_rewrite orelse std.math.maxInt(u64), st.header_trunc_pending orelse std.math.maxInt(u64), @intFromBool(st.header_held) }; + h.update(std.mem.asBytes(&words)); + } const b = &st.batch; if (b.bytes.items.len == 0) return; const words = [_]u64{ b.serial, b.node, b.handle, b.at, b.bytes.items.len, b.last_ns }; @@ -1041,8 +1050,12 @@ pub const Namespace = struct { pub fn forget(st: *Namespace, gpa: std.mem.Allocator) void { for (&st.opens) |*o| o.deinit(gpa); st.opens_len = 0; + st.results_len = 0; st.batch.bytes.deinit(gpa); st.batch = .{}; + st.header_rewrite = null; + st.header_trunc_pending = null; + st.header_held = false; } pub fn mount(st: *Namespace, gpa: std.mem.Allocator, name: []const u8, dial: []const u8) !void { diff --git a/core/ninep/tree.zig b/core/ninep/tree.zig index 107479f6..3eeb5d3f 100644 --- a/core/ninep/tree.zig +++ b/core/ninep/tree.zig @@ -126,8 +126,8 @@ pub const out_reserve = 4 * 1024; pub const Open = struct { /// A client's join carries it and the digest covers it (fs.Namespace), /// but what only its reader is answered with: the listener's held - /// read, the stream's last answer, the panes a look or exec touched. - pub const replica = .{ .authority = .{ "results", "held", "replay" } }; + /// read and the stream's last answer. + pub const replica = .{ .authority = .{ "held", "replay" } }; /// The node it was opened on, which every use checks; 0 is a free record. node: u64 = 0, what: What = .{ .snapshot = null }, @@ -216,6 +216,7 @@ pub const Open = struct { pub const Replay = struct { off: u64, bytes: []u8 }; pub const Results = struct { + pub const replica = .{ .len = .{.{ "list", "len" }} }; list: [pardes.MAX_PANES]u32 = undefined, len: u8 = 0, /// Written on: reads are a stream from the write on, whatever diff --git a/core/replica.zig b/core/replica.zig index 50615fc0..4d1a635c 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -7133,6 +7133,18 @@ test "a client joined after a script truncated a pane's tag writes the tag its s try n.agree(); } +test "a client joined after a script truncated the workspace's tag writes the tag its session writes" { + var n = try NinepJoin.init("one\n", TestHost.host()); + defer n.deinit(); + const tag: u64 = @backingInt(pardes.ctlfs.TopFile.tag); + const h = (try n.serve(.{ .tag = 1, .op = .open, .node = tag, .omode = 1 }, true)).handle; + _ = try n.serve(.{ .tag = 2, .op = .setattr, .node = tag, .handle = h, .truncate = true }, true); + try n.join(); + _ = try n.serve(.{ .tag = 3, .op = .write, .node = tag, .handle = h, .data = "Exit\n" }, true); + _ = try n.serve(.{ .tag = 4, .op = .release, .node = tag, .handle = h, .opened = true }, true); + try n.agree(); +} + test "a client joined while a chorded exec waits for its event reader's write-back runs it with its argument, as its session does" { var n = try NinepJoin.init("Msg said\narg-text\n", TestHost.host()); defer n.deinit(); |
