summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/9p_io.zig19
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;