diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 12:36:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 13:09:56 -0300 |
| commit | 9c50dd0b64ecaa8cbcfd4f76868dc83e5b9636e3 (patch) | |
| tree | 1fd44d101a680ed4ff601c8760d2f6bd4139edc0 /dev/host_io.zig | |
| parent | 1374e668fe568ad4f7f70c06156c1ecdbb8840b9 (diff) | |
| parent | c8ac386d8f2404417b6d09af1635e1104bcc66ae (diff) | |
| download | pardes-9c50dd0b64ecaa8cbcfd4f76868dc83e5b9636e3.tar.gz pardes-9c50dd0b64ecaa8cbcfd4f76868dc83e5b9636e3.zip | |
integration: the addons' workers and the daemon's notes once, on the five faults a busy machine showed: pardes-services-3 (jobs, draws, pipes and a search through the session's one queue, their workers the queue's; the daemon's notes the loop's own: eight frontend calls; an Adopt's shells kept room in a full queue; a command's exit told after its reads are applied; the tty harness's end of a case) and pardes-merge36 (pardes-faults-5); two conflicts, both where the daemon's reader starts: the faults made daemon.watch() argument-free with daemon.notesTo, the services gave the loop its own note: daemon.notesTo(&l, note) and daemon.watch(); the terminal frontend's quit arm starts no reader (kept does), and Shell.session, whose one reader that line was, is deleted; tui core-test 861/1016 (155 skipped), shell-test 1058/1061, term-test 17/17, both soaks diverged 0, unequal 0, unlisted 0, the window builds; the coordinator's gate in the ledger (reorg/merge37)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev/host_io.zig')
| -rw-r--r-- | dev/host_io.zig | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/dev/host_io.zig b/dev/host_io.zig index 5465fc7a..a22bf5ce 100644 --- a/dev/host_io.zig +++ b/dev/host_io.zig @@ -1105,6 +1105,8 @@ pub fn takeExits(core: *pardes.Pardes, ptys: anytype, ctx: anytype, comptime clo for (ptys, 0..) |*slot, id| { const pt = slotPty(slot) orelse continue; if (!pt.cmd.watched or !pt.cmd.due()) continue; + // Its output read and not yet applied (a host whose reader counts). + if (comptime @hasDecl(@TypeOf(ctx.*), "unapplied")) if (!pt.cmd.eof and ctx.unapplied(id)) continue; pt.cmd.told = true; const eof = pt.cmd.eof; core.update(.{ .exited = .{ .pane = .at(id), .status = pt.cmd.status } }); @@ -2265,11 +2267,62 @@ test "PTY EOF reserve cannot evict terminal output" { for (0..pardes.MAX_PANES) |pane| queue.push(.{ .eof = .{ .pane = .at(pane), .gen = 1 } }); var batch = queue.take(); defer for (batch.slice()) |msg| msg.deinit(gpa, gpa); - try std.testing.expectEqual(Inbox.capacity, batch.len); + try std.testing.expectEqual(Inbox.output_capacity + pardes.MAX_PANES, batch.len); for (batch.items[0..Inbox.output_capacity]) |msg| try std.testing.expectEqualStrings("before", msg.output.bytes); for (batch.items[Inbox.output_capacity..batch.len], 0..) |msg, pane| try std.testing.expectEqual(pane, msg.eof.pane.index()); } +test "a search's rows posted into a full queue wait for room: a take lets them in, a cancel ends the wait and frees them" { + const gpa = std.testing.allocator; + const io = std.testing.io; + var queue: Inbox = .{ .io = io, .gpa = gpa, .lsp_allocator = gpa }; + defer queue.deinit(); + queue.acceptReader(.at(0), 1); + const Post = struct { + fn run(q: *Inbox, posted: *?bool) void { + const rows = std.testing.allocator.dupe(u8, "a.txt:1:1-2 hit\n") catch return; + posted.* = Inbox.pushSearch(q, .{ .gen = 1, .rows = rows }); + } + }; + for ([_]bool{ false, true }) |cancel| { + // The loop busy: its queue full of output. + for (0..Inbox.output_capacity) |_| queue.push(.{ .output = .{ .pane = .at(0), .gen = 1, .bytes = try gpa.dupe(u8, "busy") } }); + var posted: ?bool = null; + var worker = try io.concurrent(Post.run, .{ &queue, &posted }); + try PtyTests.waitBlocked(&queue); + if (cancel) worker.cancel(io) else { + var batch = queue.take(); + for (batch.slice()) |msg| msg.deinit(gpa, gpa); + worker.await(io); + } + try std.testing.expectEqual(!cancel, posted.?); + var rest = queue.take(); + defer for (rest.slice()) |msg| msg.deinit(gpa, gpa); + try std.testing.expectEqual(@as(usize, if (cancel) Inbox.output_capacity else 1), rest.len); + if (!cancel) try std.testing.expectEqualStrings("a.txt:1:1-2 hit\n", rest.items[0].search.rows); + try std.testing.expectEqual(@as(usize, 0), queue.waiting); + } +} + +test "an Adopt's shells are taken in whatever output fills the queue" { + const gpa = std.testing.allocator; + var queue: Inbox = .{ .io = std.testing.io, .gpa = gpa, .lsp_allocator = gpa }; + defer queue.deinit(); + queue.acceptReader(.at(0), 1); + for (0..Inbox.output_capacity) |_| queue.push(.{ .output = .{ .pane = .at(0), .gen = 1, .bytes = try gpa.dupe(u8, "flood") } }); + var fds: [2]c_int = undefined; + if (libc.pipe(&fds) != 0) return error.PipeFailed; + defer _ = libc.close(fds[1]); + queue.push(.{ .adopted = .{ .pid = 42, .fd = fds[0] } }); + queue.push(.{ .adopted = .{ .pid = 0, .fd = -1 } }); + var batch = queue.take(); + defer for (batch.slice()) |msg| msg.deinit(gpa, gpa); + try std.testing.expectEqual(Inbox.output_capacity + 2, batch.len); + try std.testing.expectEqual(@as(libc.pid_t, 42), batch.items[Inbox.output_capacity].adopted.pid); + try std.testing.expectEqual(fds[0], batch.items[Inbox.output_capacity].adopted.fd); + try std.testing.expectEqual(@as(libc.pid_t, 0), batch.items[Inbox.output_capacity + 1].adopted.pid); +} + test "completions retain their arrival order across LSP and pipes" { const gpa = std.testing.allocator; var queue: Inbox = .{ .io = std.testing.io, .gpa = gpa, .lsp_allocator = gpa, .lsp_id = 2 }; |
