Fix deferred TLS output handling on inbound close#3324
Open
He-Pin wants to merge 1 commit into
Open
Conversation
Motivation: The GraphStage TLS engine can receive inbound completion while plaintext batching or ciphertext flushing is deferred. Its close state can then stall or complete before pending protocol output is emitted. Modification: Flush buffered ciphertext before choosing the close phase and base completion on whether the SSLEngine still requires a wrap. Add deterministic tests that hold zero-delay timers and exercise pending plaintext, buffered ciphertext, and engine wrap output. Result: Inbound close no longer strands the stage in FlushingOutbound, buffered ciphertext is emitted before completion, and pending engine output is wrapped before shutdown. Tests: - rtk sbt "stream-tests / Test / testOnly org.apache.pekko.stream.io.TlsGraphStageDeferredCloseSpec" (3 passed) - rtk sbt "stream-tests / Test / testOnly org.apache.pekko.stream.io.TlsGraphStageIsolatedSpec" (7 passed) - rtk scalafmt --list --mode diff-ref=origin/main - rtk sbt "headerCreateAll" "+headerCheckAll" - rtk git diff --check References: Refs apache#2860
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.
Motivation
TlsGraphStagemigrated the TLS pump phases fromTlsActorbut also added deferred plaintext batching and deferred transport flushing. When transport input completes before either timer runs, the copied close transition can enter a non-executableFlushingOutboundPhaseor complete before buffered ciphertext is emitted.Modification
Flush buffered transport output before selecting the close phase, and use the
SSLEngine'sNEED_WRAPstate to decide whether protocol output still has to be generated. Add deterministic tests that hold zero-delay timers and cover pending plaintext, buffered ciphertext, and engine wrap output.Result
Inbound close no longer strands the stage, already-wrapped ciphertext is delivered before completion, and pending engine output is wrapped before shutdown.
Tests
stream-tests / Test / testOnly org.apache.pekko.stream.io.TlsGraphStageDeferredCloseSpec(3 passed)stream-tests / Test / testOnly org.apache.pekko.stream.io.TlsGraphStageIsolatedSpec(7 passed)scalafmt --list --mode diff-ref=origin/mainheaderCreateAlland+headerCheckAllgit diff --checkReferences
Refs #2860