summaryrefslogtreecommitdiff
path: root/src/9p_io.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 22:18:34 -0300
committerGabriel Schneider <[email protected]>2026-10-29 23:37:00 -0300
commitddcfd860ef05c37f5536038d8828cc81c0c4125c (patch)
tree447d95dc0769273f2919747e30f5a24faec3fc21 /src/9p_io.zig
parent2d86687b98f389232b213dfa67cfa731b0280fbb (diff)
downloadpardes-ddcfd860ef05c37f5536038d8828cc81c0c4125c.tar.gz
pardes-ddcfd860ef05c37f5536038d8828cc81c0c4125c.zip
upgrade: the Upgrade word (SPC s U, a tag, 9P) moves a running session onto the pardes installed where it started, in place, by exec at a step boundary: its dump in the DumpDir, its pty masters, terminals, stubs and daemon link kept open and named on the new command line, every view and running shell its own again; the daemon re-execs too, its registry on its command line; a build that cannot load the dump falls back to the old binary, or starts afresh with the shells adopted and the dump kept (test/daemon.py --upgrade, --upgrade --gui)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/9p_io.zig')
-rw-r--r--src/9p_io.zig33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index 9bcb2827..ef6385fc 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -902,6 +902,25 @@ pub const Listener = struct {
l.posted_len = 0;
}
+ /// What the connections have still to send let go, 200 ms at most,
+ /// before they are cut (a quit, an Upgrade's exec: its write's answer).
+ pub fn flushOut(l: *Listener) void {
+ if (comptime !supported) return;
+ const deadline = nowMs() +| 200;
+ while (nowMs() < deadline) {
+ const pending = for (&l.runner.conns) |*conn| {
+ if (!conn.live()) continue;
+ conn.lock();
+ const n = conn.engine.output().len;
+ conn.unlock();
+ if (n != 0) break true;
+ } else false;
+ if (!pending) break;
+ Client.nap(1);
+ }
+ Client.nap(1); // the last bytes leave the stream's own buffer
+ }
+
pub fn deinit(l: *Listener, gpa: std.mem.Allocator) void {
l.stopping.store(true, .release);
l.unpostFromRegistry();
@@ -922,19 +941,7 @@ pub const Listener = struct {
l.edit_watchers.cancel(l.io);
// An answer given as the editor quit (a Kill written to /ctl)
// may still be on its way out: let it go before the cut.
- const deadline = nowMs() +| 200;
- while (nowMs() < deadline) {
- const pending = for (&l.runner.conns) |*conn| {
- if (!conn.live()) continue;
- conn.lock();
- const n = conn.engine.output().len;
- conn.unlock();
- if (n != 0) break true;
- } else false;
- if (!pending) break;
- Client.nap(1);
- }
- Client.nap(1); // the last bytes leave the stream's own buffer
+ l.flushOut();
l.runner.stop();
pardes.turn.wake();
}