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 /runtime | |
| 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 'runtime')
| -rw-r--r-- | runtime/session.zig | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/runtime/session.zig b/runtime/session.zig index 93b72deb..e4eb0300 100644 --- a/runtime/session.zig +++ b/runtime/session.zig @@ -6,10 +6,10 @@ //! posts, `Inbox`), its ptys (`Ptys`) and the files it watches //! (`file_watch.Watches`): a step, its unit to the clients and theirs //! taken in, an Upgrade or a Restore between steps; and the order its -//! parts end in. Its other devices (the LSP's and the pipes' and addons' -//! jobs, the session's own input) are still its frontend's (each `Shell`); -//! the language servers' answers come through its queue (`Inbox.startLsp`). -//! What a frontend does is: +//! parts end in. Its workers (a language server's query, the pipes, the +//! addons' jobs and draws, a search) answer through its queue, which holds +//! their tasks and ends them (`Inbox.land`, `Inbox.deinit`); the session's +//! own input is its frontend's (each `Shell`). What a frontend does is: //! //! - `options(o)`: before the core: what it gives the core it starts (a //! window's size, for a dump's layout). @@ -25,8 +25,6 @@ //! session's first wait (`l.watch`). //! - `sent()`: after each step's unit went to the clients. //! - `upgradeAsked()`: an Upgrade asked in the step, done (it execs). -//! - `note(n)`: what the daemon says (an adopted shell, a client's -//! connection, a new daemon's hello taken), onto its queue. //! - `restoring(nc)`, `restored(l)`: a Restore's new core, before it //! replaces the old one (its devices let go, what it is told of the //! frontend) and after (its own view of it again). @@ -90,6 +88,8 @@ pub fn Loop(comptime Frontend: type) type { l.peers = .{ .gpa = l.gpa, .io = l.io, .name = daemon.name() }; l.inbox = .{ .io = l.io, .gpa = l.gpa, .lsp_allocator = l.allocs.lsp }; defer l.inbox.deinit(); + // A search's worker may be waiting on the queue for room. + defer l.core.stream.cancelTask(); // The language servers' status lines, from the first effects on. pardes.lsp.setStatusSink(&l.inbox, host_io.Inbox.lspStatus); defer pardes.lsp.setStatusSink(null, null); @@ -100,7 +100,7 @@ pub fn Loop(comptime Frontend: type) type { l.host = try fe.open(&l); defer fe.close(&l); - daemon.notesTo(l.fe, note); + daemon.notesTo(&l, note); defer l.peers.deinit(); // Before the core goes: each client sees its link end. defer l.peers.dropAll(l.core); @@ -155,7 +155,7 @@ pub fn Loop(comptime Frontend: type) type { while (l.core.nextEffect()) |e| l.core.perform(e); } - /// What the daemon says, onto the frontend's queue (once: its + /// What the daemon says, onto the session's queue (once: its /// reader is started by the first call); and a daemon started /// since the last one died told the shells' masters it held. pub fn watch(l: *L) void { @@ -163,9 +163,20 @@ pub fn Loop(comptime Frontend: type) type { daemon.watch(); } + /// The daemon's thread: an adopted shell onto the queue (taken + /// in the frontend's wait), a client's connection to `Peers` + /// (joined at the next step boundary), a new daemon's hello taken + /// a wake (`watch` tells it the rest). fn note(ctx: *anyopaque, n: daemon.Note) void { - const fe: *Frontend = @ptrCast(@alignCast(ctx)); - fe.note(n); + const l: *L = @ptrCast(@alignCast(ctx)); + switch (n) { + .relinked => l.inbox.wake(), + .adopted => |a| { + for (a.pids[0..a.n], a.fds[0..a.n]) |pid, fd| l.inbox.push(.{ .adopted = .{ .pid = pid, .fd = fd } }); + l.inbox.push(.{ .adopted = .{ .pid = 0, .fd = -1 } }); + }, + .replica => |j| l.peers.handed(j.fd, j.view), + } } /// A Restore: the core its dump makes replaces this one, its clients @@ -174,7 +185,9 @@ pub fn Loop(comptime Frontend: type) type { fn restore(l: *L, path: []const u8) void { const nc = host_io.restoreCore(l.gpa, l.core, path, &l.peers, l.watches.fd, &l.watches.table) orelse return; l.fe.restoring(nc); - // An answer to the old core's query is turned away. + // The old core's pipes end, and an answer to its query is + // turned away. + l.inbox.pipe_tasks.cancelAll(l.io); l.inbox.discardCompletions(); l.ptys.stop(); nc.host = l.host; |
