Skip to content

fix: report a handshake reset as safe_read's failure, exit 12 - #8302

Merged
oferchen merged 2 commits into
fix/pull-trailer-role-and-daemon-exit-classfrom
fix/handshake-reset-safe-read
Nov 3, 2026
Merged

oferchen merged 2 commits into
fix/pull-trailer-role-and-daemon-exit-classfrom
fix/handshake-reset-safe-read

Conversation

@oferchen

@oferchen oferchen commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Stacked on #8287 and folded into it so the stack lands in one CI run.

Summary

Before multiplexed I/O starts, upstream reads the peer through safe_read() (io.c:351-358). A failed read() there prints safe_read failed to read %d bytes with the length the caller asked for, then exits via exit_cleanup(RERR_STREAMIO) (12). oc reported a reset at that stage as perform_io()'s read error and exited 10.

The handshake reads in setup_protocol now go through a SafeRead adapter that marks a failed read as SafeReadError carrying the requested length; read_exact reports the whole buffer, as upstream does. The client's failure mapping turns it into upstream's line and code 12. An end of stream stays on the whine_about_eof path (safe_read returns the short count, io.c:2158-2161), and a timeout stays on the check_timeout path.

Evidence (rsync 3.5.1 release tarball, replayed daemon)

Reset while reading 3.5.1 oc before oc after
the daemon's checksum list (protocol 31, negotiated strings) [Receiver] safe_read failed to read 1 bytes: Connection reset by peer (104), code 12 [Receiver] read error: ..., code 10 same as 3.5.1
the checksum seed (protocol 30) ... failed to read 4 bytes ..., code 12 read error, code 10 same as 3.5.1

Tests

  • a_reset_during_the_handshake_is_safe_reads_failure (Linux) covers both rows with the exact report lines.
  • Unit tests in setup/safe_read.rs: a reset names the requested length; EOF and timeouts are left alone.
  • Mutations, one per arm, all killed: leaving reads unmarked fails the e2e and unit tests; disabling the report arm fails the e2e test with exit 10.
  • Gates: check_rustfmt_all.py, workspace clippy -D warnings, dead_code_census.py, windows-gnu check of transfer and core; targeted nextest (transfer, core, cli) 218 passed.

Notes

  • setup_protocol serves both roles; only the client's report text and exit code change, and on a server the error displays as upstream's safe_read line.

Before multiplexed I/O starts, upstream reads the peer through
safe_read() (io.c:351-358): a failed read() is "safe_read failed to read
%d bytes" with the length the caller asked for, then
exit_cleanup(RERR_STREAMIO). oc reported perform_io()'s "read error" and
exited 10. The handshake reads in setup_protocol now mark their I/O
failures; an end of stream or a timeout keeps its own path.
@oferchen
oferchen merged commit 889f1c6 into fix/pull-trailer-role-and-daemon-exit-class Nov 3, 2026
8 checks passed
@oferchen
oferchen deleted the fix/handshake-reset-safe-read branch November 3, 2026 09:45
@github-actions github-actions Bot added the bug Something isn't working label Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant