summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-20 16:12:18 -0300
committerGabriel Schneider <[email protected]>2026-11-20 16:48:13 -0300
commit48b9b370fb60d5543afd7ba5b96bbddf06028ae2 (patch)
tree6708e0d9a319b4acda0786dafe18798463c32b68 /core/Core.zig
parent387297c3bd42c7016e36009ecf8c807259398ac7 (diff)
downloadpardes-48b9b370fb60d5543afd7ba5b96bbddf06028ae2.tar.gz
pardes-48b9b370fb60d5543afd7ba5b96bbddf06028ae2.zip
views: a view kept for its client's rejoin is that client's for away_kept_ns (30 s): the screen-state soak's 'the far client never showed the screen after the flood (it left)' (seed 0 at 207 ms, reproduced in f207-2: the far client 10.5 s behind joined again for its lag, then refused 40 times with 42 keys left, and given up) was openViewInner (Core.zig:1168) giving a join with no room the first away view (Views.close(@ctz(views_away))) while that view's client, which had said in its bye that it joins again, was still waiting for its dump to cross a slow link: a dialling client took its place and every later join of the far client was refused; FIRST the test (views.zig, the rejoin test turned round: with every view taken and two kept away, a join is refused until away_kept_ns has passed, then takes the first kept; on the base 'expected null, found 1'); then the fix: View.away_ns, the session's clock when its client went away (Views.away), and openViewInner lets a kept view go only once it is that old; the bound: the soak's far link (1 Mbit/s, 200 ms each way) has taken up to 18.3 s between two of its joins (g-1, 207 ms) and 15.6 s before; past 30 s the client is taken as gone; the wire's version 23 -> 24 (a view's state in the dump and the digest), test/daemon.py's WIRE with it; a user: a far client resyncing for its lag while a fifth client dialled lost its view and was refused (every view taken)
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig19
1 files changed, 13 insertions, 6 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 6de4f21e..de911469 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -127,6 +127,9 @@ pub const View = struct {
/// pane (util.c:467). Where the acme placement puts new panes
/// (layout.placeNew). A Look click moves the keyboard but not this.
active_column: u32 = 0,
+ /// When its client went away to join again for it (Views.away), on
+ /// the session's clock.
+ away_ns: u64 = 0,
/// The live view's frontend (Event.frontend): a window, what it draws and
/// the words it takes (builtins.zig `here`); it starts as
/// `Options.windowed` says.
@@ -1162,13 +1165,17 @@ pub inline fn view(p: anytype) if (@typeInfo(@TypeOf(p)).pointer.attrs.@"const")
pub const openView = pardes.tape.taped(openViewInner);
fn openViewInner(p: *Pardes) ?View.Id {
// Every view taken: one kept for a client that has not come back
- // for it (Views.away) goes first. ponytail: no timer lets one go;
- // until its place is wanted it costs a parked slot, and a terminal
- // it sized last keeps that size until another view types into it.
- if (@popCount(p.views_open) == Views.max and p.views_away != 0) {
- Views.close(p, @ctz(p.views_away));
+ // for it in Views.away_kept_ns (Views.away) goes first; one kept
+ // since is its client's, and the join is refused. ponytail: no timer
+ // lets one go; until its place is wanted it costs a parked slot, and
+ // a terminal it sized last keeps that size until another view types
+ // into it.
+ if (@popCount(p.views_open) == Views.max) for (0..Views.max) |k| {
+ if (!Views.isAway(p, @intCast(k)) or p.clock.now_ns -| p.views[k].?.away_ns < Views.away_kept_ns) continue;
+ Views.close(p, @intCast(k));
p.sync();
- }
+ break;
+ };
// What was queued since the last pump (a leaving client's view
// closed, a 9P request's step) done first, as every client of the
// tape does it here: a join dumps the session next, and a core