From 4592c18aa80d61a87026ca5823232ce56837f1f7 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:35:27 -0300 Subject: 9p_io: a Restore's cut lets the connections' last answers go through flushOut, which now waits on the Restore's writer too, where reset had a copy of its 200 ms loop Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/9p_io.zig | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/9p_io.zig b/src/9p_io.zig index 50c7fb95..52352684 100644 --- a/src/9p_io.zig +++ b/src/9p_io.zig @@ -477,18 +477,7 @@ pub const Listener = struct { pardes.turn.bump(&pardes.turn.epoch); pardes.turn.bump(&pardes.turn.restores); pardes.turn.rest(); - const flush_by = nowMs() +| 200; - while (nowMs() < flush_by) { - const pending = l.restore_writer.load(.acquire) or for (&l.runner.conns) |*conn| { - if (!l.cutting(conn)) continue; - conn.lock(); - const n = conn.engine.output().len; - conn.unlock(); - if (n != 0) break true; - } else false; - if (!pending) break; - nap(1); - } + l.flushOut(); for (&l.runner.conns) |*conn| if (l.cutting(conn)) conn.close(); const deadline = nowMs() +| 2000; while (nowMs() < deadline) { @@ -630,12 +619,14 @@ pub const Listener = struct { } /// What the connections have still to send let go, 200 ms at most, - /// before they are cut (a quit, an Upgrade's exec: its write's answer). + /// before they are cut (a quit, an Upgrade's exec, a Restore: its + /// write's answer, which a Restore's writer has yet to give while + /// `restore_writer` says so). pub fn flushOut(l: *Listener) void { if (comptime !supported) return; const deadline = nowMs() +| 200; while (nowMs() < deadline) { - const pending = for (&l.runner.conns) |*conn| { + const pending = l.restore_writer.load(.acquire) or for (&l.runner.conns) |*conn| { if (!conn.live()) continue; conn.lock(); const n = conn.engine.output().len; -- cgit v1.3