flush-macos-patch: Always flush after write on MacOS#159
Open
NielDuysters wants to merge 1 commit intotokio-rs:masterfrom
Open
flush-macos-patch: Always flush after write on MacOS#159NielDuysters wants to merge 1 commit intotokio-rs:masterfrom
NielDuysters wants to merge 1 commit intotokio-rs:masterfrom
Conversation
On MacOS Apple's limited and deprecated Secure Transport API is used which can cause problems when a complex stream with an internal buffering mechanism is used. We should flush after each write on MacOS to maintain a stable usage.
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.
Changes proposed in this PR.
We edited the
writemethod to always flush on MacOS.Reason for this proposal.
I'm a volunteer for The Tor Project contributing to Arti. We implement a custom struct
DataStreamused as underlying internal stream bytokio-native-tls,DataStreamimplements an internal buffering mechanism (see here) .Internal buffering was a conscious design choice to improve performance, but due to this we consistently get the error
Error: connection closed via error.whennative-tlsis used on MacOS. I suspect this has something to do withnative-tlsusing Apple's deprecated Secure Transport API which is very limited.Making sure the internal stream is always flushed after a
writemakes this crate work consistent again.This change is not ideal, but I guess it's required to make
tokio-native-tlswork stable for MacOS with more complex internal streams due to Secure Transport's limited API and deprecated state.Reproduce
When running the following test code (click here) on MacOS you'll consistently get the error
Error: connection closed via error. This because this minimal reproduction also implements an internal buffering mechanism.Edit the
Cargo.tomlof that example to implement this fork (and the changes in this PR) as patch and it will work consistently.Context
Extra context for this MR: