summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/client.zig9
-rw-r--r--runtime/session.zig2
2 files changed, 8 insertions, 3 deletions
diff --git a/runtime/client.zig b/runtime/client.zig
index 544be588..8eb01241 100644
--- a/runtime/client.zig
+++ b/runtime/client.zig
@@ -109,9 +109,10 @@ pub const Start = struct {
}
};
-/// How a client's joins ended: it quit, the session let it go, or it could
-/// not join again (`Start.said`).
-pub const Ended = enum { done, gone, failed };
+/// How a client's joins ended: it quit, the session let it go, it could
+/// not join again (`Start.said`), it left the session running (a Detach in
+/// it), or the session ended, with its code.
+pub const Ended = union(enum) { done, gone, failed, left, ended: u8 };
pub fn Loop(comptime Frontend: type) type {
return struct {
@@ -170,6 +171,8 @@ pub fn Loop(comptime Frontend: type) type {
// What it made since it joined, kept for its next start.
if (s.have) |h| h.keep(s.r.core());
s.r.deinit();
+ if (link.left) return .left;
+ if (link.ended) |code| return .{ .ended = code };
return if (link.gone) .gone else .done;
}
// The session again, the core it leaves held meanwhile: its
diff --git a/runtime/session.zig b/runtime/session.zig
index 0ef0a8ab..5d7eff78 100644
--- a/runtime/session.zig
+++ b/runtime/session.zig
@@ -141,6 +141,8 @@ pub fn Loop(comptime Frontend: type) type {
if (l.core.quit) break;
if (l.core.takeRestore()) |rp| l.restore(rp);
}
+ // The clients' last word: the session ended (Exit).
+ l.peers.ended(0);
// Its serve threads read the core: they end first.
if (l.fs) |f| {
f.deinit(l.gpa);