diff options
| -rw-r--r-- | src/Stream.zig | 25 | ||||
| -rw-r--r-- | src/tape.zig | 3 | ||||
| -rw-r--r-- | test/cross_replay.py | 12 |
3 files changed, 26 insertions, 14 deletions
diff --git a/src/Stream.zig b/src/Stream.zig index 665241df..263a6628 100644 --- a/src/Stream.zig +++ b/src/Stream.zig @@ -708,19 +708,28 @@ pub fn runHere(p: *Pardes, gen: u32) void { }; defer job.deinit(); job.waits = false; - var got: Collect = .{ .gpa = p.gpa }; - defer got.batches.deinit(p.gpa); - { - pardes.turn.yield(); - defer pardes.turn.back(); - work(std.Io.Threaded.global_single_threaded.io(), job, &got, Collect.take); - } - for (got.batches.items) |*b| { + // Its reads a site of the tape's (a 9P write's Grep or Find runs here): + // a replica takes the batches the session got, as it takes a worker's + // (Event.search), and reads no file. + const batches = pardes.tape.site(.search, p.gpa, searchHere, .{ p.gpa, job }); + defer p.gpa.free(batches); + for (batches) |*b| { receive(p, b); b.deinit(p.gpa); } } +/// The whole search, its batches gpa's. +fn searchHere(gpa: std.mem.Allocator, job: *Job) []Batch { + var got: Collect = .{ .gpa = gpa }; + work(std.Io.Threaded.global_single_threaded.io(), job, &got, Collect.take); + return got.batches.toOwnedSlice(gpa) catch { + for (got.batches.items) |b| b.deinit(gpa); + got.batches.deinit(gpa); + return &.{}; + }; +} + const Collect = struct { gpa: std.mem.Allocator, batches: std.ArrayList(Batch) = .empty, diff --git a/src/tape.zig b/src/tape.zig index e446c06a..9152bcb0 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -94,6 +94,8 @@ pub const Site = enum(u16) { kind, probe, preview, + /// A search run on the loop (Stream.runHere: a 9P write's Grep or Find). + search, // Read in place (`value`). clock, budget, @@ -132,6 +134,7 @@ pub const results = .{ anyerror![]u8, anyerror!void, terminal.Told, ?pardes.ctlfs.pty.Printed, @typeInfo(@TypeOf(terminal.greeting)).@"fn".return_type.?, + []pardes.Stream.Batch, // What only the authority holds (`authority`): a closed pane's record, // Recent's entry for a closed jump, the closed panes' names. ?@import("Store.zig").Record, ?@import("recent.zig").Entry, diff --git a/test/cross_replay.py b/test/cross_replay.py index 6c5a1e4d..9ce7d152 100644 --- a/test/cross_replay.py +++ b/test/cross_replay.py @@ -17,11 +17,11 @@ The session meets the host's failures, whose errors cross by name: a Look of a fifo (a read the host refuses) and of a directory, a stat and a read under /os over 9P, a Save into a file as if it were a directory and a Restore of a dump that is not there (errors the host reports, anyerrors). -And it holds what a digest must name the same in every build: a -+LocationsConfig, whose origin is a Builtin, and a file pane renamed (H19: -no Linux client could join a FreeBSD session so). ponytail: no Grep or -Find, which a 9P write runs on the loop, its reads no tape site (a replay -of it panics, by any build). +It greps and finds, as a script does, which a 9P write runs on the loop: +its reads are a tape site (a replica of a session a script greps in read +no file and diverged). And it holds what a digest must name the same in +every build: a +LocationsConfig, whose origin is a Builtin, and a file +pane renamed (H19: no Linux client could join a FreeBSD session so). """ import os import shutil @@ -75,7 +75,7 @@ def record(binary, out): started.append(int(status['pid'])) pane = next(int(row.split()[0]) for row in c.read('/index').splitlines() if row.split()[1] == b'text') for line in (f'Look {root / "fifo"}', f'Look {root / "dir"}', f'Save {root / "a.txt" / "x"}', - f'Restore {root / "nothing.dump"}', 'LocationsConfig'): + f'Restore {root / "nothing.dump"}', 'Grep hello', 'Find txt', 'LocationsConfig'): try: c.write(f'/pane/{pane}/exec', line.encode() + b'\n') except Exception: |
