summaryrefslogtreecommitdiff
path: root/runtime/session.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 15:13:48 -0300
committerGabriel Schneider <[email protected]>2026-11-20 15:34:15 -0300
commitfb7e632248c599a70689cd0451392c8a890044ee (patch)
tree8fafe9377885a50f2e49c0710f37c5268c980e42 /runtime/session.zig
parent0957cd7ad097c83a591e315f2e261996e72ea856 (diff)
downloadpardes-fb7e632248c599a70689cd0451392c8a890044ee.tar.gz
pardes-fb7e632248c599a70689cd0451392c8a890044ee.zip
daemon: the reader hands no note to a session loop that ended: it took the loop's address once, at its start, and ran on until main's daemon.quit joined it, after Loop.run returned, so a client connecting (or a shell adopted, or a daemon relinked) while a session ended was handed to the loop's dead frame (l.peers, l.inbox, deinit'ed); now the reader hands each note under a lock to where notesTo says (daemon.give), the session loop sets it after its frontend opened and clears it (notesTo(null)) before its peers, frontend and queue go, and a note with nowhere to go is let go, its connections closed; test "a client's connection the daemon hands on after the session's loop ended reaches no loop: it is closed" (a fake daemon on a socketpair link): "expected 0, found 1" (the ended loop handed it) on the base, passes now; a user could hit it: a pardes attach (or Adopt's answer) in the moment its session exits: a write into a dead stack frame (a crash or a corrupted teardown)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'runtime/session.zig')
-rw-r--r--runtime/session.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/session.zig b/runtime/session.zig
index 9c8446e3..a0c27799 100644
--- a/runtime/session.zig
+++ b/runtime/session.zig
@@ -101,10 +101,13 @@ pub fn Loop(comptime Frontend: type) type {
l.host = try fe.open(&l);
defer fe.close(&l);
- daemon.notesTo(&l, note);
defer l.peers.deinit();
// Before the core goes: each client sees its link end.
defer l.peers.dropAll(l.core);
+ // The daemon's notes, to the loop until its state goes (the
+ // reader runs on until main's `daemon.quit`).
+ daemon.notesTo(.{ .ctx = &l, .deliver = note });
+ defer daemon.notesTo(null);
// A first client on the socket it was started with, before its
// first effects: it has every terminal from its first byte, and
// no reload (Core.openView).