Repository navigation
fix(socket): retry interrupted plain TCP reads and writes - #1802
Merged
Merged
Conversation
The plain TCP socket_read, socket_write and socket_write_vectored, and the read_tls call of FrontRustls::socket_read, mapped an interrupted syscall (EINTR) to SocketResult::Error, which closes a healthy session on the pipe path and on the mux paths that close a session whose client write failed. Retry it at once, as flush_tls does since #1795. The plain write bodies move into plain_socket_write and plain_socket_write_vectored, generic over the transport like plain_socket_read, so tests can script an interrupted write; the logging stays in tcp_socket_write and tcp_socket_write_vectored. Fixes #1799 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
Resolve the CHANGELOG: separate the handshake entry from the #1802 entry with a blank line, and replace #1802's sentence that the handshake pump keeps its mapping, which this branch makes false. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
Bring in the squash of this branch's base, #1789, with #1775, #1798 and #1802. The squash carries the same changes as the base branch head this branch had merged, so lib/src/protocol/mux/mod.rs, lib/src/protocol/mux/LIFECYCLE.md, doc/lifetime_of_a_session.md, e2e/src/tests/tls_tests.rs and CHANGELOG.md are resolved by keeping this branch's edits to that content over main: the net change of this branch against origin/main is the same as it was against the base branch head. The CHANGELOG keeps one copy of the #1779 entry and one blank line between entries. Re-pin the `readable()`, `writable()` and `flush_output_to_socket()` code blocks of doc/h2_mux_internals.md to their lines in the merged h2.rs. Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
## Summary The TLS handshake still treated an interrupted syscall (`EINTR`) as fatal: - `handshake_read` (`lib/src/protocol/rustls.rs`) sent an `Interrupted` error from `read_tls` to its generic arm, `HandshakeReadFault::ReadTls`, and `TlsHandshake::readable` closed the session; - the write pump of `TlsHandshake::writable` sent an `Interrupted` error from `write_tls` to its generic arm, which logged `Could not perform handshake` and closed the session. Both now retry the syscall at once, as `flush_tls` (#1795) and `rustls_socket_read` / the plain socket paths (#1802) do in `lib/src/socket.rs`. Only the syscall is retried. Readiness handling, the `ShortReadProbe` (it records only a successful read, so `was_short` stays exact) and the `READ_RESET`/`WRITE_RESET` counters are unchanged. The handshake write moves into `handshake_write`, which is generic over the transport like `handshake_read`, so a test can interrupt it. With #1802 merged, this was the last socket path that still treated `EINTR` as fatal. `origin/main` is merged into this branch, first at `11f12b76`, then at `82058124` (after #1789 and #1804). The first merge separates the two CHANGELOG entries with a blank line and replaces #1802's sentence "The TLS handshake pump … keeps its mapping" with one saying the pump now retries the same way. The second merge keeps both sets of tests in `lib/src/protocol/rustls.rs`, where this branch and #1789 each added tests at the same spot. The code merged cleanly. Fixes #1799 ## Tests - `an_interrupted_handshake_read_is_retried`: the first `recv` returns `Interrupted`. The test asserts that the retry reads the whole ClientHello short, READABLE drops, and the server queues its flight. - `an_interrupted_handshake_write_is_retried`: the first write returns `Interrupted`. The test asserts that the retry writes the flight and the client processes it. I wrote both tests before the retry arms, and both failed: `an interrupted read must be retried, not reported: ReadTls(Kind(Interrupted))` and `an interrupted write must be retried, not reported: Kind(Interrupted)`. After the fix, both pass. ## Validation (on the merge commit `07b036e8`) - `cargo +nightly fmt --check` -> exit 0 - `cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings` -> exit 0 - `cargo +1.93.1 test -p sozu-lib --lib --all-features --locked` -> `test result: ok. 1570 passed; 0 failed` - `python3 .github/scripts/check_doc_citations.py --root . --base origin/main` -> exit 0 - `cargo test -p sozu-e2e --features opentelemetry,splice,simd tls -- --test-threads=4` -> `test result: ok. 44 passed; 0 failed` - `cargo test -p sozu-e2e --features opentelemetry,splice,simd -- --test-threads=4 half_close client_fin max_connections` -> `test result: ok. 12 passed; 0 failed` Signed-off-by: Florentin Dubois <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1799
#1795 made
flush_tlsretry an interrupted write (EINTR). The other socket paths inlib/src/socket.rsstill answeredSocketResult::Errorfor it, which closes a healthy session on the pipe path and, with #1793, on the H1 and h2c mux paths. They now retry the call at once:plain_socket_read(plainsocket_read);plain_socket_write(plainsocket_write), inside the existingMAX_LOOP_ITERATIONSbudget;plain_socket_write_vectored(plainsocket_write_vectored);read_tlscall ofrustls_socket_read(FrontRustls::socket_read): rustls propagates the transport'sInterruptedfromread_tls; the retry is tight around it, so the plaintext drain and the short-read probe are unaffected.The plain write bodies move from
tcp_socket_write/tcp_socket_write_vectoredintoplain_socket_write/plain_socket_write_vectored, generic over the transport likeplain_socket_read, so tests can script an interrupted write. Counters are unchanged and stay in the bodies; the logging (same tiers and messages) stays in thetcp_*wrappers throughPlainWriteFault.Tests (each red with its retry arm removed, green with it):
an_interrupted_plain_write_is_retriedan_interrupted_plain_vectored_write_is_retriedan_interrupted_plain_read_is_retriedan_interrupted_tls_read_is_retriedCHANGELOG.mdanddoc/lifetime_of_a_session.mdupdated.Not in this PR: the TLS handshake pump (
handshake_readand the handshakewrite_tlsarm inlib/src/protocol/rustls.rs) keeps the same mapping.