diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 07:33:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 14:27:36 -0300 |
| commit | 5671a8275203334594b6f3b548e6a6012ef9fae6 (patch) | |
| tree | ee18ce296eea19620efdca231ee0de30b66c33f9 | |
| parent | 90ba0ef908dd65b322676f7a0f6edc5b7b976242 (diff) | |
| download | pardes-5671a8275203334594b6f3b548e6a6012ef9fae6.tar.gz pardes-5671a8275203334594b6f3b548e6a6012ef9fae6.zip | |
ninep: a client that joins a session with 9P work under way has the 9P state the session has: what a step reads that the requests made is the core's state like any other (P30, P35), so the walk sees it: fs leaves Pardes's and Pane's authority lists and the 9P server's own part says so in its types (fs.Namespace: the sockets, mounts, log, the request being served's flags and the rest; pane.State: the event and pty readers' queues and counts, winsize, unannounced; Open: the listener's held read and a stream's last answer; LogOpen whole), so the open records, the writes held to go in as one edit (fs.batch) and each pane's addr, limit, dot truncation, wrsel, joined, nomark, noscroll, lock, run, unmarked, tag truncation and chord are in every dump and in the digest; the digest is cheap by type: a pane's 9P state adds nothing for a pane no script has touched and its fields as one run of bytes for the rest (pane.State.digest), the namespace the opens in use and held writes by their length (Namespace.digest: a 9P body append hashed its whole batch, +0.14% on body-appends), so the frame and perf gate's 121 per-operation counts are within 0.1% of tree2 (largest client-key-down +0.054%; the plain walk of the same state cost client-key-down +0.73%); an open's union is named (Open.What) and digests what a step reads of it (its kind, a run, an event reader's flag, a pager's serial, a port's index), never the text its reader is answered with, which each process makes of its own state (walk.hash takes a tagged union's own digest as it takes a struct's); the opens are taken as far as fs.opens_len (an idle session's none; the scans that read records bound by it, openOf too, and an open lets go of what a rollback left in its record past the length); a session revived from a dump (Restore, an Upgrade, a start from one: dump.loadAndRevive; a closed pane brought back: loadPane) drops the opens and each pane's 9P state, as today, its connections gone (fs.Namespace.forget): a client's join loads alone and keeps them; not the join's dump alone: the tape's dump round trip at a replay's end wants the image to carry what the digest covers; pty.Run's answer cut at its length; the wire version 24, so the semantics word moves 64e89d6b25a84796 -> 18636a639ac075de (it did not move with the walk alone: a base client would have digested other fields than its session; test/daemon.py's WIRE with it, and its upgrade case takes a client of the other side's protocol saying `run the same pardes at both ends`, as its third terminal already did); the eleven tests of the change before pass; a join's dump (the probe, Debug): idle 63258 -> 64612 bytes, 50 opens held 63270 -> 66744; the image idle 233426 -> 237001, 50 opens 233738 -> 295089; tui core-test 867/1022 (155 skipped), shell-test 1062/1065, behaviour-test 275/275 and --replay 275/275, replicas --clients 5 diverged 0/0/0, unequal 0, unlisted stops 0, corpus 22 of 22, no leak (load 30-40, before the digests were made cheap; the whole gate on the change after)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | abi/wire.zig | 4 | ||||
| -rw-r--r-- | core/Core.zig | 10 | ||||
| -rw-r--r-- | core/Plumb.zig | 4 | ||||
| -rw-r--r-- | core/dump.zig | 5 | ||||
| -rw-r--r-- | core/exec.zig | 2 | ||||
| -rw-r--r-- | core/fs.zig | 50 | ||||
| -rw-r--r-- | core/ninep/events.zig | 4 | ||||
| -rw-r--r-- | core/ninep/pane.zig | 22 | ||||
| -rw-r--r-- | core/ninep/pty.zig | 1 | ||||
| -rw-r--r-- | core/ninep/tree.zig | 95 | ||||
| -rw-r--r-- | core/panes.zig | 5 | ||||
| -rw-r--r-- | core/walk.zig | 6 | ||||
| -rw-r--r-- | test/daemon.py | 5 |
13 files changed, 162 insertions, 51 deletions
diff --git a/abi/wire.zig b/abi/wire.zig index a36e746b..4055e42d 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -10,6 +10,8 @@ const pardes = @import("core"); const config = @import("pardes_options"); const build_info = @import("build_info"); +/// 24: the 9P state a session's requests made (its open records, each +/// pane's) is in its join's dump and its digest (core/fs.zig Namespace); /// 23: a pane of a kind's frame names its rasters by key, their pixels /// crossing before it as strips of 4 MiB at most over the rows it shows /// (screen kind 5), and a replica lacking one asks for its pane again @@ -36,7 +38,7 @@ const build_info = @import("build_info"); /// part B); 14: the hello names a session and /// carries the semantics hash, and a ping is answered (phase 5's /// groundwork); 13: the frames went (phase 3). -pub const version: u16 = 23; +pub const version: u16 = 24; /// The terminal's build and the window's step alike (`semantics`). const family = switch (config.platform) { diff --git a/core/Core.zig b/core/Core.zig index da1dc4b8..f75a9ccd 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -469,11 +469,11 @@ pub const replica = .{ "tape", }, .derived = .{ "shell_rows", "diff_output", "locations_cache", "retired_panes", "tty_filter_palette", "body_chrome" }, - // The host's handles, the 9P server's fids and log, the state file - // every session of the user shares (and Recent read from it), this - // session's closed panes, and the files of a host with no file - // system of its own. - .authority = .{ "host", "fs", "store", "recent", "db", "fallback" }, + // The host's handles, the state file every session of the user + // shares (and Recent read from it), this session's closed panes, and + // the files of a host with no file system of its own. (The 9P + // server's own part of `fs` says so in fs.Namespace.) + .authority = .{ "host", "store", "recent", "db", "fallback" }, .len = .{ .{ "look_src", "n_look_src" }, .{ "session_dir", "session_dir_len" }, .{ "session_home", "session_home_len" }, .{ "session_shell", "session_shell_len" } }, }; diff --git a/core/Plumb.zig b/core/Plumb.zig index f51ddace..e1b09e69 100644 --- a/core/Plumb.zig +++ b/core/Plumb.zig @@ -593,7 +593,7 @@ pub fn portName(p: *const Pardes, index: u8) ?[]const u8 { /// Whether a program reads port `index` (an open of its file): the /// authority's 9P state, asked through the tape. fn portRead(p: *Pardes, index: u8) bool { - for (&p.fs.opens) |*o| if (o.node != 0 and o.what == .port and o.what.port.index == index) return true; + for (p.fs.opens[0..p.fs.opens_len]) |*o| if (o.node != 0 and o.what == .port and o.what.port.index == index) return true; return false; } @@ -611,7 +611,7 @@ fn enqueue(p: *Pardes, q: *events.Queue, lead: []const u8, m: *const Msg) bool { /// A copy of `m` to every reader of port `index` (plumber(4)'s queuesend: /// every fid open when it was sent), each read held for one answered. fn fanOut(p: *Pardes, index: u8, m: *const Msg) void { - for (&p.fs.opens) |*o| if (o.node != 0 and o.what == .port and o.what.port.index == index) { + for (p.fs.opens[0..p.fs.opens_len]) |*o| if (o.node != 0 and o.what == .port and o.what.port.index == index) { if (!enqueue(p, &o.what.port.queue, "", m)) { var said: Kind.Buf(160) = .{}; events.notePath(p, "err -", said.print("plumb/{s}: a message of {d} bytes is over a reader's {d} KiB, not sent to it", .{ portName(p, index).?, m.data.len, events.queue_cap / 1024 })); diff --git a/core/dump.zig b/core/dump.zig index c348dec2..8c37d800 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -574,6 +574,10 @@ fn loadAndRevive(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, previ var on_disk: OnDisk = @splat(false); const p = try loadKnowing(gpa, opts, bytes, ¬es, &on_disk); errdefer p.deinit(); + // The 9P state its requests made was its connections', which do not + // come with it (a client's join loads alone, and keeps it). + p.fs.forget(gpa); + for (p.panes) |slot| if (slot) |pane| pane.fs.deinit(gpa); // Its kinds are this process's, not the dump's: the session's it // replaces, or what the scan found (a dump of another session's). p.kinds = if (previous) |old| old.kinds else .started(p.tape, opts.addons); @@ -750,6 +754,7 @@ pub fn loadPane(p: *Pardes, id: usize, bytes: []const u8) !*pardes.panes.Pane { pane.command_from = 0; pane.places.from = 0; pane.collapsed = false; + pane.fs.deinit(p.gpa); pane.prompt_view = p.live; try ensureKind(p, pane); p.installPane(id, pane); diff --git a/core/exec.zig b/core/exec.zig index 18b519ff..52f54541 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -799,7 +799,7 @@ pub fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { /// Whether an open of a look or exec file holds `serial` from its own write /// (tree.Open.results): its client is reading that pane. fn leased(p: *const Pardes, serial: u32) bool { - for (p.fs.opens) |o| if (o.node != 0 and o.results.wrote) { + for (p.fs.opens[0..p.fs.opens_len]) |o| if (o.node != 0 and o.results.wrote) { if (std.mem.indexOfScalar(u32, o.results.list[0..o.results.len], serial) != null) return true; }; return false; diff --git a/core/fs.zig b/core/fs.zig index 6e5829e1..dcc33cd6 100644 --- a/core/fs.zig +++ b/core/fs.zig @@ -841,6 +841,30 @@ 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 + /// 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 + /// on their own), the log and what a reader or a listener is answered + /// with, and the request being served's own flags, set and read in + /// its step. ponytail: `edit_hold`, set by the session's listener + /// between steps and read by the retried write's step, is no + /// replica's (reports/pardes-faults-4.md). + pub const replica = .{ + .authority = .{ + "socket_path", "tcp_address", "mounts", "node_name", "os_paths", "out", + "listeners", "origin", "no_prompt", "session_write", "unlogged", "capturing", + "serving", "refused", "failure", "failure_len", "no_pane_slot", "no_pane_slot_len", + "said", "said_len", "said_at", "late_failure", "late_failure_len", + "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", + }, + .len = .{.{ "opens", "opens_len" }}, + }; socket_path: []const u8 = "", tcp_address: ?std.Io.net.IpAddress = null, mounts: std.ArrayList(Mount) = .empty, @@ -848,6 +872,9 @@ pub const Namespace = struct { os_paths: std.ArrayList(OsPath) = .empty, /// What each open holds between its open and its release. opens: [tree.open_slots]tree.Open = @splat(.{}), + /// The records past it are free: a digest and a dump take the opens + /// this far (an idle session's none). + opens_len: u8 = 0, out: std.ArrayList(u8) = .empty, listeners: u16 = 0, origin: u8 = 'K', @@ -995,6 +1022,29 @@ pub const Namespace = struct { st.out.deinit(gpa); } + /// 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 + /// 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"); + for (st.opens[0..st.opens_len]) |*o| pardes.walk.hash(tree.Open, o, h); + 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 }; + h.update(std.mem.asBytes(&words)); + } + + /// What the requests of connections gone made, let go: a session + /// revived from a dump has none of the connections that held its opens. + pub fn forget(st: *Namespace, gpa: std.mem.Allocator) void { + for (&st.opens) |*o| o.deinit(gpa); + st.opens_len = 0; + st.batch.bytes.deinit(gpa); + st.batch = .{}; + } + pub fn mount(st: *Namespace, gpa: std.mem.Allocator, name: []const u8, dial: []const u8) !void { if (!validMountName(name)) return error.BadMountName; try ninep_io.Client.validateDial(dial); diff --git a/core/ninep/events.zig b/core/ninep/events.zig index 1951a434..1fd05b54 100644 --- a/core/ninep/events.zig +++ b/core/ninep/events.zig @@ -332,7 +332,7 @@ fn newest(p: *Pardes) ?struct { at: usize, seq: u64, text: []const u8 } { /// Whether a follower has read the record `seq`, or is part way through it. fn followerRead(p: *Pardes, seq: u64) bool { - for (p.fs.opens) |o| if (o.node != 0 and o.what == .log) { + for (p.fs.opens[0..p.fs.opens_len]) |o| if (o.node != 0 and o.what == .log) { const l = o.what.log; if (l.follow and (l.next > seq or (l.next == seq and l.part > 0))) return true; }; @@ -437,6 +437,8 @@ fn pushLog(p: *Pardes, raw: []u8) void { /// What an open of /log holds. pub const LogOpen = struct { + /// Its reader's alone: what it is answered with (the log is the session's). + pub const replica = .{ .authority = .{ "bytes", "follow", "next", "part", "pos" } }; /// The ring's text when it was opened. bytes: []const u8 = &.{}, /// This open waits for records after `bytes`, from `next`. diff --git a/core/ninep/pane.zig b/core/ninep/pane.zig index 1d514a3c..d47b637b 100644 --- a/core/ninep/pane.zig +++ b/core/ninep/pane.zig @@ -30,6 +30,28 @@ const Node = tree.Node; /// Filesystem state a pane carries beside its editor state. pub const State = struct { + /// What a step reads of it is digested and dumped (fs.Namespace); the + /// readers' records and the server's say of them are the session's. + pub const replica = .{ .authority = .{ "readers", "event_reader", "events", "tag_snap", "pty_reader", "pty_out", "winsize", "unannounced" } }; + + /// Its digest (core/walk.zig): nothing for a pane no script has set + /// anything of (most of them, at every unit a replica confirms); the + /// rest's fields as one run of bytes, not a hash's call a field. + pub fn digest(st: *const State, h: *pardes.walk.Hasher) void { + const untouched: State = .{}; + var touched = false; + inline for (comptime pardes.walk.fieldNames(State)) |name| touched = touched or !std.meta.eql(@field(st, name), @field(untouched, name)); + if (!touched) return; + var buf: [256]u8 = undefined; + var w: std.Io.Writer = .fixed(&buf); + // Longer than the room (a chord's text): field by field. + if (encoded(st, &w)) |_| h.update(w.buffered()) else |_| inline for (comptime pardes.walk.fieldNames(State)) |name| pardes.walk.hash(@FieldType(State, name), &@field(st, name), h); + } + + fn encoded(st: *const State, w: *std.Io.Writer) std.Io.Writer.Error!void { + inline for (comptime pardes.walk.fieldNames(State)) |name| try pardes.walk.encode(@FieldType(State, name), &@field(st, name), w); + } + /// The range `data` and `xdata` read and write through. acme clears it /// when the first client opens `addr` (editors/acme/xfid.c:105-108), /// which suits a client that holds the fid open; a shell cannot, and diff --git a/core/ninep/pty.zig b/core/ninep/pty.zig index 4b0cee66..ec752311 100644 --- a/core/ninep/pty.zig +++ b/core/ninep/pty.zig @@ -164,6 +164,7 @@ pub const output_rows = output_cap / 8; /// What an open of run holds (tree.zig's open records). pub const Run = struct { + pub const replica = .{ .len = .{.{ "answer", "len" }} }; /// `waiting`: the line is kept until the shell's first prompt (a new /// terminal's shell takes a moment to draw it), then sent. phase: enum { idle, waiting, sent, done } = .idle, diff --git a/core/ninep/tree.zig b/core/ninep/tree.zig index 1eaaa8cb..107479f6 100644 --- a/core/ninep/tree.zig +++ b/core/ninep/tree.zig @@ -124,9 +124,45 @@ pub const out_reserve = 4 * 1024; /// (editors/acme/dat.h:373-385). An open that holds something answers its /// record's index plus one as the handle; one that holds nothing answers 0. 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" } }; /// The node it was opened on, which every use checks; 0 is a free record. node: u64 = 0, - what: union(enum) { + what: What = .{ .snapshot = null }, + /// What a write to a file of command lines left unfinished: a last line + /// with no newline yet, or an Edit block still open. A write through a + /// mount is cut at the 9P message size, so one `echo` of many lines may + /// come as several writes, cut anywhere; the rest waits for the open's + /// next write, or its release, and never runs as a fragment. + pending: std.ArrayList(u8) = .empty, + /// The panes this open's last write touched, which a read of look or + /// exec on it answers, as /net/tcp/clone answers on the open that + /// asked; a fresh open holds the session's last, from before it opened. + results: Results = .{}, + /// A read that found nothing yet (`.again`), kept to be answered when + /// this open's file has something, the way factotum keeps its log's + /// waiting reads and answers them on append (security/auth/factotum/ + /// log.c:4-52) and acme an event read (editors/acme/xfid.c:994). One at a + /// time, as acme's window keeps one `eventx`: a newer read takes the + /// place of the older. The listener fills it in and answers it + /// (runtime/9p_io.zig, `answerHeld`). + held: ?Held = null, + /// The last answer a stream open (a followed log, event, pty/data) gave, + /// and the offset it was read at. A read at an offset inside it is + /// answered from it again: bash's `read` takes a chunk, keeps a line and + /// lseeks back to just past it, and a stream has already moved on. + replay: ?Replay = null, + /// A `name` open has named its pane: one name an open, so a second line + /// on it (bash writes `printf 'a\nb\n'` a line at a time) is refused. + named: bool = false, + /// A line over 1 MiB was refused: what follows of it, through its + /// newline, is dropped rather than run as a line of its own. + discarding: bool = false, + + /// What it is an open of, and what that holds. + pub const What = union(enum) { /// /screen's frame from the open, a terminal body's history from its /// first read. snapshot: ?[]const u8, @@ -160,36 +196,22 @@ pub const Open = struct { /// An open reading a plumb port (Plumb.zig's ports, plumber(4)'s): /// the messages sent to it since the open, packed, a read each. port: struct { index: u8, queue: events.Queue = .{} }, - } = .{ .snapshot = null }, - /// What a write to a file of command lines left unfinished: a last line - /// with no newline yet, or an Edit block still open. A write through a - /// mount is cut at the 9P message size, so one `echo` of many lines may - /// come as several writes, cut anywhere; the rest waits for the open's - /// next write, or its release, and never runs as a fragment. - pending: std.ArrayList(u8) = .empty, - /// The panes this open's last write touched, which a read of look or - /// exec on it answers, as /net/tcp/clone answers on the open that - /// asked; a fresh open holds the session's last, from before it opened. - results: Results = .{}, - /// A read that found nothing yet (`.again`), kept to be answered when - /// this open's file has something, the way factotum keeps its log's - /// waiting reads and answers them on append (security/auth/factotum/ - /// log.c:4-52) and acme an event read (editors/acme/xfid.c:994). One at a - /// time, as acme's window keeps one `eventx`: a newer read takes the - /// place of the older. The listener fills it in and answers it - /// (runtime/9p_io.zig, `answerHeld`). - held: ?Held = null, - /// The last answer a stream open (a followed log, event, pty/data) gave, - /// and the offset it was read at. A read at an offset inside it is - /// answered from it again: bash's `read` takes a chunk, keeps a line and - /// lseeks back to just past it, and a stream has already moved on. - replay: ?Replay = null, - /// A `name` open has named its pane: one name an open, so a second line - /// on it (bash writes `printf 'a\nb\n'` a line at a time) is refused. - named: bool = false, - /// A line over 1 MiB was refused: what follows of it, through its - /// newline, is dropped rather than run as a line of its own. - discarding: bool = false, + + /// What a step reads of it: not the text a reader is answered from + /// (a screen, a listing, the log, a port's messages), which each + /// process makes of its own state, and a replica never answers. + pub fn digest(w: *const What, h: *pardes.walk.Hasher) void { + const tag = std.meta.activeTag(w.*); + pardes.walk.hash(@TypeOf(tag), &tag, h); + switch (w.*) { + .run => |*run| pardes.walk.hash(pty.Run, run, h), + .event => |*reader| pardes.walk.hash(bool, reader, h), + .pager => |*serial| pardes.walk.hash(u32, serial, h), + .port => |*port| pardes.walk.hash(u8, &port.index, h), + .snapshot, .log, .frozen, .pty_data, .ctl, .lines, .writes, .plumb => {}, + } + } + }; pub const Replay = struct { off: u64, bytes: []u8 }; @@ -230,7 +252,7 @@ pub const open_slots = 64; /// The record a request's handle names, when it was opened on that node. pub fn openOf(p: *Pardes, req: Req) ?*Open { - if (req.handle == 0 or req.handle > p.fs.opens.len) return null; + if (req.handle == 0 or req.handle > p.fs.opens_len) return null; const o = &p.fs.opens[req.handle - 1]; return if (o.node == req.node) o else null; } @@ -614,7 +636,7 @@ fn runAttr(p: *Pardes, req: Req, target: Target) ?Reply.Attr { .top, .col, .port => return null, }; if (t.file != .pty_run) return null; - const run = if (req.handle != 0) openOf(p, req) else for (&p.fs.opens) |*o| { + const run = if (req.handle != 0) openOf(p, req) else for (p.fs.opens[0..p.fs.opens_len]) |*o| { if (o.node == req.node and o.what == .run) break o; } else null; if ((run orelse return null).what != .run) return null; @@ -895,7 +917,7 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { .ctl => if (linesOpen(target, req)) .lines else .{ .frozen = &.{} }, // One writer of the rules at a time, as plumber(4)'s. .rules, .send => if (req.omode & 3 == 0) return .{ .tag = req.tag } else plumb: { - if (f == .rules) for (p.fs.opens) |o| if (o.node == req.node and o.what == .plumb) return failText(req.tag, E.BUSY, e_in_use); + if (f == .rules) for (p.fs.opens[0..p.fs.opens_len]) |o| if (o.node == req.node and o.what == .plumb) return failText(req.tag, E.BUSY, e_in_use); break :plumb .plumb; }, else => if (linesOpen(target, req)) .lines else return .{ .tag = req.tag }, @@ -934,7 +956,11 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { // record would be another than the session's. const i = p.tape.authority(freeOpen, .{p}) orelse return Reply.fail(req.tag, E.NFILE); const o = &p.fs.opens[i]; + // Past `opens_len` a replica's record may hold what a rollback did not + // put back (rollback.zig saves records as far as it says). + if (o.node != 0) o.deinit(p.gpa); o.* = .{ .node = req.node, .what = what }; + p.fs.opens_len = @max(p.fs.opens_len, @as(u8, @intCast(i + 1))); if (resultsFile(target)) { @memcpy(o.results.list[0..p.fs.results_len], p.fs.results[0..p.fs.results_len]); o.results.len = p.fs.results_len; @@ -1074,6 +1100,7 @@ fn releaseHandle(p: *Pardes, req: Req) void { .snapshot, .log, .lines, .writes, .frozen, .pager, .plumb, .port => {}, }; o.deinit(p.gpa); + while (p.fs.opens_len > 0 and p.fs.opens[p.fs.opens_len - 1].node == 0) p.fs.opens_len -= 1; } fn setattr(p: *Pardes, req: Req, target: Target) Reply { diff --git a/core/panes.zig b/core/panes.zig index 1c103bd1..68304437 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -27,12 +27,11 @@ pub const EditText = struct { text: []u8, row0: i32 }; pub const Pane = struct { /// What the replay digest leaves out (core/walk.zig): the view's geometry, - /// made again from the rest (File.geometry); the 9P server's record of - /// the pane's opens and readers; the other views' share of it (views.zig). + /// made again from the rest (File.geometry); the other views' share of + /// it (views.zig). (The 9P server's part of `fs` says so in its type.) pub const replica = .{ .local = .{ "pv", "pv_known" }, .derived = .{ "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "notices", "pan" }, - .authority = .{"fs"}, .len = .{ .{ "msg", "msg_len" }, .{ "msg_older", "msg_older_len" }, .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } }, // A picture's memory is its own allocator's (a dump loaded makes // it there). diff --git a/core/walk.zig b/core/walk.zig index 6d7c594d..9b760144 100644 --- a/core/walk.zig +++ b/core/walk.zig @@ -31,8 +31,9 @@ //! .blob = .{ "content" }, //! }; //! -//! None of the three kinds is in a digest or a dump. A type with a `pub fn -//! digest(*const T, *Hasher) void` of its own hashes itself; one with +//! None of the three kinds is in a digest or a dump. A type (a struct or a +//! tagged union) with a `pub fn digest(*const T, *Hasher) void` of its own +//! hashes itself; one with //! `dumpWrite`, `dumpRead` (and `dumpFree`) dumps itself as bytes. const std = @import("std"); const xitdb = @import("xitdb"); @@ -242,6 +243,7 @@ pub fn hash(comptime T: type, v: *const T, h: *Hasher) void { }, .@"union" => |u| { if (u.tag_type == null) @compileError("walk: an untagged union: " ++ @typeName(T)); + if (comptime @hasDecl(T, "digest") and @TypeOf(T.digest) == fn (*const T, *Hasher) void) return v.digest(h); const tag: u.tag_type.? = v.*; hash(u.tag_type.?, &tag, h); switch (v.*) { diff --git a/test/daemon.py b/test/daemon.py index d134732b..775a487b 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -236,7 +236,7 @@ class Replica: """A replica's connection (abi/wire.zig): length-prefixed messages, a tag byte and a little-endian u32 length. It is a near client: its first word after the hello says so.""" - WIRE = 23 + WIRE = 24 def __init__(self, path, timeout=10): self.path, self.timeout = path, timeout @@ -2004,7 +2004,8 @@ def upgrades(old, new): # build's own, let go (a session shows one frontend of its own now), # its stub told. wait_for('the second terminal redrawn or let go', lambda: b'\x1b[?1049h' in term2.text()[before[1]:] or - (stub2.poll() is not None and (b'detached from' in term2.text() or b'upgrade this client too' in term2.text()))) + (stub2.poll() is not None and (b'detached from' in term2.text() or b'upgrade this client too' in term2.text() or + b'run the same pardes at both ends' in term2.text()))) wait_for('the word said', lambda: 'Upgrade: now pardes' in screen_text(client)) # The daemon lists the session under its new build. said = Replica(root / 'pardes-replica.sock').hello('work', new_build) |
