summaryrefslogtreecommitdiff
path: root/dev/host_io.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 06:07:10 -0300
committerGabriel Schneider <[email protected]>2026-11-20 06:07:21 -0300
commit26d0581168ac4b582025ecb01b36968850344811 (patch)
treeb91cab46612fa48c55d7ec93fbe802af5da6bf23 /dev/host_io.zig
parent8d9f4c88072089b53c77ab7e66b01c461fbbee74 (diff)
downloadpardes-26d0581168ac4b582025ecb01b36968850344811.tar.gz
pardes-26d0581168ac4b582025ecb01b36968850344811.zip
runtime, dev: the daemon's notes are the session loop's own, so `note` leaves the frontend calls (nine to eight: options, open, close, start, sent, upgradeAsked, restoring, restored): the loop's note puts an adopted shell on its queue (both frontends take it in their wait), hands a client's connection to Peers (joined at the next step boundary, its post the wake, as the window did) and wakes the queue for a new daemon's hello; the terminal's deliverNote, its adopted and replica messages and arms (in apply and in Own.close's drain) and the window's deliverNote and both Own.note are deleted, the terminal's Shell names its session loop (`session`) so that a quit before the first frame starts the daemon's reader through the loop's watch; and the test first: an Adopt's shells arriving while output fills the queue were dropped by Inbox.push, their masters closed and the shells lost with them (448 outputs in, the shell and the end of the list pushed, 448 taken), in the window today, and in the terminal once its notes came through this queue (vaxis's queue had made the daemon's thread wait); the queue now keeps room for one Adopt's shells beyond the output's (adopt_capacity, the ring 64 + 1 longer, the output's bound unchanged) and each pane's end of file beyond those; a user could have hit it: Adopt in a window while another pane floods; tui core-test 858/1009 (151 skipped), shell-test 1049/1052, term 17/17, pane 183/184, kitty 45/45, behaviour-test and --replay 275/275, process-test 0 of 144 failed (msg, pagercolor and exec-bigdrag failed once in the run, passed on their retries), soak --clients 5 diverged 0, unequal 0, checked/wrong 1874/0 1937/0 1831/0, quiet checks 597/0 673/0 779/0, unlisted 0, corpus 22 of 22, no leak; --bytes --clients 5 diverged 0, unequal 0, quiet checks 693/0 586/0 802/0, corpus 22 of 22, no leak, its one unlisted stop at `now` the base's; gui unit-test 1646/1650 with only BaselineHarnessMismatch; daemon.py plain, --far, --games (keys stopped 0 and 0), --window-clients, --upgrade both ways pass (load 8-22)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'dev/host_io.zig')
-rw-r--r--dev/host_io.zig21
1 files changed, 20 insertions, 1 deletions
diff --git a/dev/host_io.zig b/dev/host_io.zig
index 1c4fe332..0efb37fd 100644
--- a/dev/host_io.zig
+++ b/dev/host_io.zig
@@ -2265,7 +2265,7 @@ 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());
}
@@ -2302,6 +2302,25 @@ test "a search's rows posted into a full queue wait for room: a take lets them i
}
}
+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 };