diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/replica.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/replica.zig b/core/replica.zig index edab01ee..97da9c74 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -3112,13 +3112,16 @@ 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 near link cut with no last word (`why` its hang-up) whose session this -/// machine's daemon lists still: an Upgrade's exec cut it, a dump on the -/// way past the clients' flush (`Peers.refuseAll`), 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. -pub fn cutListed(why: []const u8, session: []const u8) bool { +/// 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'); @@ -3170,7 +3173,7 @@ pub fn join(gpa: Allocator, j: *Joined, path: []const u8, session: []const u8, o sameBuild(gpa, (dial(gpa, path, session, why, have, null) orelse // 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 (have == null and cutListed(why, session))) redial(gpa, path, session, why, have, true, null) else null) orelse return null, why)) orelse return null; + 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 = &.{}; |
