diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 09:10:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 09:10:24 -0300 |
| commit | c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437 (patch) | |
| tree | 9b60bce9e53f96855b40f2ba53e23945a7798ddf /core/replica.zig | |
| parent | f7de6f49ee3d9ac241575f5244743193c9943841 (diff) | |
| parent | 5ad6067936f306271b875aaf182d4866055da10d (diff) | |
| download | pardes-c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437.tar.gz pardes-c4f7bb9477c7aa4c8864f14edb9e85b6c8c08437.zip | |
integration: the pair's round 5 and the layers' round 2 on the gathered line: pardes-pair-5 (`ssrtxkzx`, on pardes-merge48: a link an Upgrade cuts with no last word asks the daemon whether its session is listed still and joins again (`replica.cutListed`): an upgrade from the installed build carries its clients; a no-daemon pair refuses Restore in words (P42); /dev/tty opened before the pair forks; a TERMed or hung-up client dies of the signal; the process suite as pairs 13 to 8 of 145) and pardes-layers-2 (`myxnnquu`, on pardes-merge49: the click on path@rev tested, a revision read-only from 9P, Syntax off in a patch keeps the patch's colours); no conflict; core-test 893/1053 (160 skipped), shell-test 1095/1098; its gate: .scratch/sketch/reorg/merge50, the numbers in PARDES.md (2026-11-21)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/core/replica.zig b/core/replica.zig index 56fc4a59..97da9c74 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -3112,6 +3112,26 @@ pub fn ended(why: []const u8) bool { /// What an Upgrade tells its clients (`Peers.refuseAll`): each dials again. pub const upgrading = "the session is upgrading to another build of pardes"; +/// A link cut with no last word (`why` its hang-up) whose session its +/// daemon lists still: an Upgrade's exec cut it, a dump on the way past the +/// clients' flush (`Peers.refuseAll`), whichever build the session is, not +/// the session's end, which the daemon sees as its link's: so the client +/// joins again as one told `upgrading` does, whatever the flush's bound let +/// through. Near, this machine's daemon is asked; far, the dial again is +/// the asking (the far daemon's "no session called" ends it: `redial`). +pub fn cutListed(why: []const u8, session: []const u8, far: bool) bool { + if (!std.mem.startsWith(u8, std.mem.sliceTo(why, 0), "the session hung up")) return false; + if (far) return true; + var buf: [8192]u8 = undefined; + const list = daemon.ask("list", &buf) orelse return false; + var lines = std.mem.tokenizeScalar(u8, list, '\n'); + while (lines.next()) |line| { + if (!std.mem.startsWith(u8, line, "session ")) continue; + if (std.mem.eql(u8, line[(std.mem.lastIndexOfScalar(u8, line, ' ') orelse continue) + 1 ..], session)) return true; + } + return false; +} + /// The words a client goes with when its session runs another build now. const upgrade_words = "session upgraded to a newer pardes: upgrade this client too"; @@ -3151,8 +3171,9 @@ pub fn join(gpa: Allocator, j: *Joined, path: []const u8, session: []const u8, o redial(gpa, path, session, why, have, true, v) else sameBuild(gpa, (dial(gpa, path, session, why, have, null) orelse - // Handed to the session as it upgraded: it is there again soon. - if (std.mem.eql(u8, std.mem.sliceTo(why, 0), upgrading)) redial(gpa, path, session, why, have, true, null) else null) orelse return null, why)) orelse return null; + // Handed to the session as it upgraded, or cut by its exec with + // its dump on the way: it is there again soon. + if (std.mem.eql(u8, std.mem.sliceTo(why, 0), upgrading) or cutListed(why, session, have != null)) redial(gpa, path, session, why, have, true, null) else null) orelse return null, why)) orelse return null; defer { if (have) |h| h.store(gpa, j) else gpa.free(j.dump); j.dump = &.{}; @@ -3280,6 +3301,9 @@ fn redial(gpa: Allocator, path: []const u8, session: []const u8, why: *[600]u8, _ = std.fmt.bufPrint(why, "{s}\x00", .{upgrade_words}) catch {}; return null; } + // Its daemon lists no such session: it is gone, not away a moment + // (an Upgrade keeps it listed throughout). + if (std.mem.startsWith(u8, words, "no session called ")) return null; if (!patient or tries > 200) return null; const ts: libc.timespec = .{ .sec = 0, .nsec = 100 * std.time.ns_per_ms }; _ = libc.nanosleep(&ts, null); |
