Skip to content

Conversation

@NielDuysters
Copy link

Changes proposed in this PR.

We edited the write method 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 DataStream used as underlying internal stream by tokio-native-tls, DataStream implements 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. when native-tls is used on MacOS. I suspect this has something to do with native-tls using Apple's deprecated Secure Transport API which is very limited.

Making sure the internal stream is always flushed after a write makes this crate work consistent again.

This change is not ideal, but I guess it's required to make tokio-native-tls work 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.toml of 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:

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant