Repository navigation
fix(rustls): retry an interrupted handshake read or write - #1803
Merged
Merged
Conversation
handshake_read and the write pump of TlsHandshake::writable treated a read_tls or write_tls the kernel interrupted (EINTR) as fatal: they logged "Could not perform handshake" and closed a healthy session. EINTR says nothing about the socket, so both now retry the syscall at once, as flush_tls does after the handshake. The readiness, the short-read probe and the reset counters are unchanged. The handshake write moves into handshake_write, generic over the transport like handshake_read, so a test can interrupt it. Covered by an_interrupted_handshake_read_is_retried and an_interrupted_handshake_write_is_retried, both red without the retry. Refs #1799 Signed-off-by: Florentin Dubois <[email protected]>
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]>
Resolve lib/src/protocol/rustls.rs: this branch and #1789 each added tests after a_full_handshake_read_reads_again. Keep both: the EINTR handshake tests, then #1789's ClientHello-then-FIN tests. The code merged cleanly, so the EINTR retries in handshake_read and handshake_write sit beside #1789's routine-close handling and HUP-during-handshake close. Reflow the handshake paragraph of doc/lifetime_of_a_session.md, which the automatic merge left with one overlong line. Signed-off-by: Florentin Dubois <[email protected]>
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.
Summary
The TLS handshake still treated an interrupted syscall (
EINTR) as fatal:handshake_read(lib/src/protocol/rustls.rs) sent anInterruptederror fromread_tlsto its generic arm,HandshakeReadFault::ReadTls, andTlsHandshake::readableclosed the session;TlsHandshake::writablesent anInterruptederror fromwrite_tlsto its generic arm, which loggedCould not perform handshakeand closed the session.Both now retry the syscall at once, as
flush_tls(#1795) andrustls_socket_read/ the plain socket paths (#1802) do inlib/src/socket.rs. Only the syscall is retried. Readiness handling, theShortReadProbe(it records only a successful read, sowas_shortstays exact) and theREAD_RESET/WRITE_RESETcounters are unchanged. The handshake write moves intohandshake_write, which is generic over the transport likehandshake_read, so a test can interrupt it.With #1802 merged, this was the last socket path that still treated
EINTRas fatal.origin/mainis merged into this branch, first at11f12b76, then at82058124(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 inlib/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 firstrecvreturnsInterrupted. 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 returnsInterrupted. 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))andan 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 0cargo +1.93.1 clippy --all-features --all-targets --locked -- -D warnings-> exit 0cargo +1.93.1 test -p sozu-lib --lib --all-features --locked->test result: ok. 1570 passed; 0 failedpython3 .github/scripts/check_doc_citations.py --root . --base origin/main-> exit 0cargo test -p sozu-e2e --features opentelemetry,splice,simd tls -- --test-threads=4->test result: ok. 44 passed; 0 failedcargo test -p sozu-e2e --features opentelemetry,splice,simd -- --test-threads=4 half_close client_fin max_connections->test result: ok. 12 passed; 0 failed