diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:35:27 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 00:58:28 -0300 |
| commit | 4592c18aa80d61a87026ca5823232ce56837f1f7 (patch) | |
| tree | d55a2eb9807203a64c84d80ab8590031a8c4f337 /src | |
| parent | 6753d41e80f2227c0cf56cc03fa5b6e0e116db27 (diff) | |
| download | pardes-4592c18aa80d61a87026ca5823232ce56837f1f7.tar.gz pardes-4592c18aa80d61a87026ca5823232ce56837f1f7.zip | |
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
| -rw-r--r-- | src/9p_io.zig | 19 |
1 files changed, 5 insertions, 14 deletions
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; |
