From ef0ec0f2025f596823ea98dc6088d0d63432bb81 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 12:22:50 -0300 Subject: a message written over 9P to a session idle for a while lingers its full time: its stamp and the unattended expiry read the clock again, through the tape Moving them onto the session clock (now_ns, for the replay) stamped a message with the last pump's time: written over 9P after an idle spell longer than MessageLinger, it was as old as the spell and an unattended session expired it at once (fs.py's unattended_messages_expire failed when its session sat idle first). Both read CLOCK_MONOTONIC as before, as a taped value, so a replica reads the recording's. Co-Authored-By: Claude Opus 5.5 --- src/Messages.zig | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Messages.zig b/src/Messages.zig index 4cf81ac5..e1d18849 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -197,7 +197,9 @@ fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void { const arrives = pane.msg_len == 0 or pane.msg_life.phase == .leaving; for (text[0..n], pane.msg[0..n]) |c, *cell| cell.* = if (c < 0x20 or c == 0x7f) ' ' else c; pane.msg_len = @intCast(n); - pane.msg_said_ms = @intCast(p.now_ns / std.time.ns_per_ms); + // The clock when it was said (the session clock is the last pump's, + // and a 9P write after an idle hour would say it an hour ago). + pane.msg_said_ms = pardes.tape.value(.clock, nowMs, .{}); p.needs_frame = true; if (arrives) { pane.msg_life = .{ .phase = if (p.settings.message_animation and n > 0) .entering else .shown }; @@ -219,11 +221,17 @@ fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void { /// while a step is out and must change nothing. /// ponytail: a pane's older lines go with its newest, not each on its own /// clock; the render pipeline's clock will give every line its own. +fn nowMs() i64 { + if (comptime !pardes.hosted) return 0; + var ts: std.c.timespec = undefined; + if (std.c.clock_gettime(.MONOTONIC, &ts) != 0) return 0; + return @as(i64, ts.sec) * 1000 + @divTrunc(@as(i64, ts.nsec), 1_000_000); +} + pub fn expireUnattended(p: *Pardes) void { if (!p.unattended) return; - // The session's clock (`advance`), as every tick's: no replica reads - // its own. - const now: i64 = @intCast(p.now_ns / std.time.ns_per_ms); + // The clock as the session that recorded read it (src/tape.zig). + const now = pardes.tape.value(.clock, nowMs, .{}); for (p.panes) |slot| { const pane = slot orelse continue; if (pane.msg_len == 0 and pane.msg_older_len == 0) continue; -- cgit v1.3