diff options
Diffstat (limited to 'runtime/client.zig')
| -rw-r--r-- | runtime/client.zig | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/runtime/client.zig b/runtime/client.zig index 329bdab3..d20e64d1 100644 --- a/runtime/client.zig +++ b/runtime/client.zig @@ -185,7 +185,9 @@ pub fn Loop(comptime Frontend: type) type { upgrade.locate(); while (true) { link.reset(s.r, &s.joined); - l.fe.start(l); + if (s.joined.booted) { + if (!l.confirm(s)) return .failed; + } else l.fe.start(l); var done: std.atomic.Value(bool) = .init(false); const reader = try std.Thread.spawn(.{}, read, .{ l, s, &done }); while (!link.quit) { @@ -226,6 +228,28 @@ pub fn Loop(comptime Frontend: type) type { } } + /// A pair's first join, its replica its own boot (replica.ownBoot): its + /// start's inputs held and its first pass drawn, then the session's + /// welcome read: the same core, what was held is sent; another (the + /// dump came), the dump's replica in place of the boot's, started + /// again. False, and why in `s.why`: no session to go on with. + fn confirm(l: *L, s: *Start) bool { + const link = &l.link; + link.held = .empty; + l.fe.start(l); + _ = l.before(); + const r = replica.confirmBoot(s.gpa, &s.joined, s.r, s.o, &s.why) orelse { + link.release(s.gpa, false); + return false; + }; + link.release(s.gpa, r == s.r); + if (r == s.r) return true; + s.r = r; + link.reset(r, &s.joined); + l.fe.start(l); + return true; + } + /// The session's stream, onto the frontend's queue: its messages, /// and its end. fn read(l: *L, s: *Start, done: *std.atomic.Value(bool)) void { |
