From efbb9bb38b800deb47e581fd7b0a7ea06d504122 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 20 Nov 2026 09:36:22 -0300 Subject: attachClient: a far attach dials the forwarded socket until a connect answers, within the same 30 s, not only until its file is there: ssh binds the socket (its file) a moment before it listens, and a client that dialled between the two was told 'nothing answers at .../pardes-ssh-N.sock' (4 of 40 attaches through test/daemon.py's stand-in ssh at a load of 38-45; 10 of 10 with 0.5 s between its bind and listen); the probe is cloud9's connectFd, closed at once, then the client dials as before: 0 of 40 and 0 of 20 refused-name attaches with the 0.5 s; test/delay_relay.py --bound MS holds a socket bound that long before listening, and daemon.py --far's ssh uses 500; after, pinned to one CPU: 0 of 40, and 0 of 20 with the 0.5 s; the five together: tui core-test 859/1014, shell-test 1055/1058, pane-test 183/184, term-test 17/17, kitty-test 45/45, behaviour-test 275/275 and --replay, process-test 0 of 144 (cmdexit once, again alone), daemon.py in every mode, both soaks diverged 0 unequal 0, gui unit-test 1651/1655 (BaselineHarnessMismatch), the frame and perf gate against tree2 PASS Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/daemon.py | 9 +++++---- test/delay_relay.py | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/daemon.py b/test/daemon.py index 2bc0cca6..f8402af2 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -1491,12 +1491,13 @@ def far(binary): f_join = joins(root / 'f.stats')[0] assert f_join['from_disk'] > 0 and cached(cache) <= (1 << 20) + (64 << 10), (f_join, cached(cache)) far_joins(root / 'pardes-replica.sock', 'files', binary, 200) - # Through ssh (a stand-in forwarding as `ssh -L` does): a client - # refused and one detached each end their ssh and its socket (one - # refused left both, 2026-10-30). + # Through ssh (a stand-in forwarding as `ssh -L` does, its socket + # bound 0.5 s before it listens: the client dials until it answers): + # a client refused and one detached each end their ssh and its + # socket (one refused left both, 2026-10-30). fake = root / 'ssh' fake.write_text('#!/bin/sh\nwhile [ $# -gt 0 ]; do case $1 in -L) fwd=$2; shift;; esac; shift; done\n' - f'exec {sys.executable} -B {Path(__file__).parent / "delay_relay.py"} "${{fwd%%:*}}" "${{fwd#*:}}" --delay 0\n') + f'exec {sys.executable} -B {Path(__file__).parent / "delay_relay.py"} "${{fwd%%:*}}" "${{fwd#*:}}" --delay 0 --bound 500\n') fake.chmod(0o755) senv = dict(env, PARDES_SSH=str(fake), PARDES_REMOTE_RUNTIME=str(root), TMPDIR=str(root)) diff --git a/test/delay_relay.py b/test/delay_relay.py index c600a3aa..b0d48e38 100644 --- a/test/delay_relay.py +++ b/test/delay_relay.py @@ -8,7 +8,7 @@ the ones before it have crossed at that rate, then waits out the delay. An optional jitter adds up to that many ms more to each chunk's delay, at random, its order kept (a chunk never overtakes the one before it). - python3 -B test/delay_relay.py LISTEN TARGET --delay MS [--rate MB/s] [--jitter MS] + python3 -B test/delay_relay.py LISTEN TARGET --delay MS [--rate MB/s] [--jitter MS] [--bound MS] python3 -B test/delay_relay.py --self-check An address is a path (a Unix socket) or host:port (TCP). The one-way @@ -46,7 +46,9 @@ def dial(address): return s -def listen(address): +def listen(address, bound=0.0): + """Bound, then listening `bound` s later (an ssh -L's socket file is + there a moment before it answers).""" family, addr = parse(address) s = socket.socket(family) if family == socket.AF_UNIX: @@ -57,6 +59,7 @@ def listen(address): else: s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(addr) + time.sleep(bound) s.listen(64) return s @@ -260,8 +263,9 @@ def main(): ap.add_argument('--delay', type=float, required=True, help='one-way delay, ms') ap.add_argument('--rate', type=float, help='a bandwidth cap, MB/s') ap.add_argument('--jitter', type=float, default=0, help='up to this many ms more a chunk, at random') + ap.add_argument('--bound', type=float, default=0, help='ms between the bind and the listen') a = ap.parse_args() - listener = listen(a.listen) + listener = listen(a.listen, a.bound / 1000) print(f'relaying {a.listen} -> {a.target}, {a.delay} ms each way' + (f', {a.rate} MB/s' if a.rate else '') + (f', jitter {a.jitter} ms' if a.jitter else ''), flush=True) try: -- cgit v1.3