diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 05:54:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 06:12:41 -0300 |
| commit | 4eb6252d35abba437ac672cc20025b75bef8f217 (patch) | |
| tree | 484135ac7c9064f06a84a957a333fb3002b97252 | |
| parent | 16f4a216e45fe8425d594d04803287eb3557bdf9 (diff) | |
| download | pardes-4eb6252d35abba437ac672cc20025b75bef8f217.tar.gz pardes-4eb6252d35abba437ac672cc20025b75bef8f217.zip | |
remote client: a link's end read before the drain, not after it: the link reader posts `link_gone` just before it marks its end, so a drain that tested the mark last could leave that post queued, and the next link (a rejoin after divergence or an Upgrade) took it and ended at once, the client saying 'let this client go' right after 'joined again' (test/daemon.py's forced divergence, about one run in ten under load)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | src/tty/tty.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 08964d73..994ebd92 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -1585,15 +1585,18 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se if (init.environ_map.get("PARDES_REPLICA_STATS")) |file| link.writeStats(file); if (!link.gone) replica.bye(joined.fd); // The link's reader ends with the link, posting as it goes: what it - // and the terminal posted is let go until it has. + // and the terminal posted is let go until it has. Its end is read + // before the drain, not after: its last post (`link_gone`) comes + // just before it, and left queued it ended the next link at once. _ = libc.shutdown(joined.fd, 2); while (true) { + const ended = reader_done.load(.acquire); while (loop.tryEvent() catch null) |ev| switch (ev) { .unit, .screen, .refused => |b| std.heap.c_allocator.free(b), .paste => |b| gpa.free(@constCast(b)), else => {}, }; - if (reader_done.load(.acquire)) break; + if (ended) break; std.Thread.yield() catch {}; } reader.join(); |
