diff options
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/replica.zig b/core/replica.zig index 97da9c74..3c7a5cbc 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -2346,10 +2346,21 @@ pub const Peers = struct { ps.recording = true; ps.samples = std.c.getenv("PARDES_REPLICA_STATS") != null; } + // A join with no room lets go a view kept past its bound by the + // core's clock (Core.openView), which a wake by mail alone, as this + // join's, does not move (tui.zig `clockNow`): moved now, on the tape. + if (@popCount(core.views_open) == pardes.views.max) if (core.host.call(.now, .{})) |now| core.advance(now); const k = viewFor(core, joining.view) orelse { core.unattended = ps.count() == 0 and ps.detached; if (ps.count() == 0) ps.stop(core); - return daemon.refuseReplica(fd, "that session has as many views as it takes"); + const full = "that session has as many views as it takes"; + var left: u64 = 0; + for (0..pardes.views.max) |i| if (pardes.views.isAway(core, @intCast(i))) { + const n = (core.views[i].?.away_ns + pardes.views.away_kept_ns) -| core.clock.now_ns; + left = if (left == 0) n else @min(left, n); + }; + var why: [128]u8 = undefined; + return daemon.refuseReplica(fd, if (left == 0) full else std.fmt.bufPrint(&why, full ++ " (one is kept {d} s more for a client joining again)", .{(left + std.time.ns_per_s - 1) / std.time.ns_per_s}) catch full); }; ps.seq += 1; ps.unit(0, ps.seq); |
