a73x

6149c54d

test: the half-frame leg witnesses the ACCEPT, not just the write

a73x   2026-08-28 19:53

Commit message
test: the half-frame leg witnesses the ACCEPT, not just the write

A unix connect() succeeds into the listen backlog, so the peer's marker
said the byte was written and not that the daemon held it — and an
unaccepted half frame parks nothing, which is the precondition the leg
exists to guarantee. The daemon's own /proc fd table answers it.

test/e2e_01_boot.sh
Old New
@@ -974,12 +974,22 @@ SOCKHF="${TMPDIR:-/tmp}/muxd-e2e-halfframe-$$.sock"
974 start_daemon "$SOCKHF" "$OUT.hf.d" "half-frame daemon never bound" --shell /bin/sh 974 start_daemon "$SOCKHF" "$OUT.hf.d" "half-frame daemon never bound" --shell /bin/sh
975 DHFPID=$DPID 975 DHFPID=$DPID
976 HFMARK="$OUT.hf.sent"; defer_rm "$HFMARK" 976 HFMARK="$OUT.hf.sent"; defer_rm "$HFMARK"
977 # The daemon's OWN fd table, sampled before the peer exists: a unix
978 # connect() succeeds into the listen backlog, so the peer's marker below
979 # says the byte was written and NOT that the daemon has it. What the leg
980 # needs is an ACCEPTED half frame — an unaccepted one parks nothing — and
981 # the accept is a socket appearing in /proc. Ask the OS about the OS.
982 HFDPID=$(real_pid "$DHFPID")
983 HFFD0=$(find "/proc/$HFDPID/fd" -mindepth 1 2>/dev/null | wc -l)
984 [ "$HFFD0" -gt 0 ] || {
985 echo "e2e FAIL: half-frame: cannot read /proc/$HFDPID/fd, so the accept"
986 echo " below could not be witnessed"; exit 1; }
977 python3 - "$SOCKHF" "$HFMARK" <<'EOF' & 987 python3 - "$SOCKHF" "$HFMARK" <<'EOF' &
978 import socket, sys, time 988 import socket, sys, time
979 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 989 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
980 s.connect(sys.argv[1]) 990 s.connect(sys.argv[1])
981 s.sendall(b'\x06') # stats_req's kind byte, and nothing after it 991 s.sendall(b'\x06') # stats_req's kind byte, and nothing after it
982 open(sys.argv[2], 'w').write('sent\n') # the byte is queued on the daemon's side 992 open(sys.argv[2], 'w').write('sent\n') # written; the accept is asserted below
983 time.sleep(60) 993 time.sleep(60)
984 EOF 994 EOF
985 HFPID=$! 995 HFPID=$!
@@ -990,6 +1000,18 @@ defer_kill "$HFPID"
990 # answer, and the leg goes green having tested nothing. 1000 # answer, and the leg goes green having tested nothing.
991 wait_for "$HFMARK" sent 5 || { 1001 wait_for "$HFMARK" sent 5 || {
992 echo "e2e FAIL: half-frame: peer never connected"; tail -30 "$OUT.hf.d"; exit 1; } 1002 echo "e2e FAIL: half-frame: peer never connected"; tail -30 "$OUT.hf.d"; exit 1; }
1003 # ...and then the accept, which is the half of the precondition the marker
1004 # cannot speak for. Nothing else connects in this window, so one more fd is
1005 # this peer's.
1006 _hfi=0
1007 while [ "$(find "/proc/$HFDPID/fd" -mindepth 1 2>/dev/null | wc -l)" -le "$HFFD0" ]; do
1008 _hfi=$((_hfi + 1))
1009 [ "$_hfi" -lt $(( 100 * TIME_SCALE )) ] || {
1010 echo "e2e FAIL: half-frame: the daemon never accepted the peer, so the"
1011 echo " stats below would not have been asked behind one"
1012 tail -30 "$OUT.hf.d"; exit 1; }
1013 sleep 0.05
1014 done
993 set +e 1015 set +e
994 timeout $((5 * TIME_SCALE)) "$MUXD" stats --sock "$SOCKHF" > "$OUT.hf.st" 2>&1 1016 timeout $((5 * TIME_SCALE)) "$MUXD" stats --sock "$SOCKHF" > "$OUT.hf.st" 2>&1
995 HFRC=$? 1017 HFRC=$?