-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore NotConnected error in poll_shutdown() #42
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable to me based on what you found in #41
WDYT about adding some brief context to the commit message?
0c0c9ca
to
8c9d6f3
Compare
Added some context to the commit message. |
I ran into this issue as well with reqwest. This commit definitely reduces the amount of errors that I get, but it doesn't fix it completely. When testing hitting https://google.com 100 times, I actually start getting different responses than I get with openssl AND I occasionally get this error now:
I suspect that maybe EOF errors need to be ignored as well? |
These are the 3 responses I get: openssl only returns this one:
rust-tls sometimes returns this one as well as the one above
And then still occasionally returns:
|
I think this is being addressed upstream (hyperium/hyper#3427, hyperium/h2#743) and is separate from the concerns of this branch. See also the Rustls manual's section on Unexpected EOF. The other two responses seem fine to me. The choice of the server's 301 or 302 response doesn't seem obviously tied to Rustls. |
I added h2 as a dependency and pointed it to the git repo:
But I still get the error:
|
These are my reqwest dependencies:
|
Wouldn't you need to point your Since this seems unrelated to the change in this PR I think it would be more appropriate to discuss in a separate issue. |
Yep I agree. I actually wasn't able to test updating h2 alongside this fix as there were compiler errors when I cloned reqwest. I'm just going to stick to using openssl for now and will circle back around to rustls when reqwest updates with the patches :). Thanks for the help! :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for delay, I just finished my Spring Festival vacation.
A more reasonable approach is to record a state to ensure that write_io
is no longer called after call io.shutdown
. but that's fine too.
src/common/mod.rs
Outdated
ready!(self.write_io(cx))?; | ||
match ready!(self.write_io(cx)) { | ||
Ok(_) => {} | ||
Err(err) if err.kind() == io::ErrorKind::NotConnected => {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it should break
? otherwise it could loop infinitely.
No worries, hope you had a nice vacation!
Ahh, you think this is because #41 states it's happening because the peer closed the connection. |
8c9d6f3
to
addf108
Compare
Pushed changes to:
|
I'm think about something like this fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
while !self.start_shutdown && self.session.wants_write() {
ready!(self.write_io(cx))?;
}
self.start_shutdown = true;
Pin::new(&mut self.io).poll_shutdown(cx)
} I believe this is because the signal has been emitted when |
Interesting! For what it's worth yesterday I spent a little bit of time trying to write a test for this condition. I couldn't manage to get @Revanee Out of curiosity, in #41 when you were observing this issue were you testing on MacOS? |
@cpu I've tested it on Arch Linux with kernel [package]
name = "proxy_test"
version = "0.1.0"
edition = "2021"
[dependencies]
hyper = { version = "1.1.0", features = ["full"] }
hyper-util = { version = "0.1.1", features = ["full"] }
tokio = { version = "1.18.1", features = ["macros", "rt-multi-thread", "sync"] }
tokio-native-tls = "0.3.1"
tokio-rustls = "0.25.0"
rustls-pemfile = "2.0.0" |
🤔 Very interesting. Thanks!
Thanks I'll take a look. I didn't start with this repo since my goal was to figure out an in-tree test (e.g. not using a |
addf108
to
813f0fe
Compare
813f0fe
to
cf32e6c
Compare
Okay, I've pushed a simpler fix, can you test this? |
@Revanee do you have time to test this soon? We'd like to get a new release out soonish with the rustls 0.23 upgrade, and it would be nice to ship a fix for this at the same time. |
@djc I tested the new fix and it works! :) |
Thanks! @quininer what do you think of this? It seems like the minimal fix that addresses the observed issue, we can always extend this to more cases if they are encountered in the wild by someone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think this is good, at least it doesn't bring risks. |
Fixes #41.