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
UnixStream::connect() doesn't handle EPOLLHUP #3879
Comments
I'm not too familiar with Tokio's source code, @Darksonn do you know if |
Hm, it's rather difficult to trace whether it does. |
I believe that |
Looking at: tokio/tokio/src/net/unix/stream.rs Lines 53 to 54 in 0b93bd5
It doesn't seem to check any errors set on the stream, something that tokio/tokio/src/net/tcp/stream.rs Lines 146 to 152 in 0b93bd5
Could that be the problem? In any case I think epoll/Mio should return an error that is detectable (somewhere) by Tokio before the stream is returned by |
I opened #3898 to make the change that @Thomasdezeeuw suggested. |
I found out this weekend that EPOLLHUP isn't necessarily a terminal state - it can mean the listen socket's accept backlog is full and that it'll start accepting new connections again once the backlog clears. I've never seen this issue with libuv (I'm a maintainer) but maybe that's because libuv doesn't register the file descriptor with EPOLLRDHUP. I can try removing EPOLLRDHUP from Tokio/mio and see if that makes a difference, or do you expect that to break things? |
I'm a little confused; the original issue is about Also can mean sounds rather troublesome. How would we detect a "real" problem from a backlog is full try again problem? Can use
We use it to determine if the read side is closed: https://docs.rs/mio/0.7.13/mio/event/struct.Event.html#method.is_read_closed.
Well it would break the public API of Mio for sure. If you want to try the relevant code is here: https://github.com/tokio-rs/mio/blob/21ddf94d3191dc2385d53ca8f2ac5a7b5ca5af96/src/sys/unix/selector/epoll.rs#L136. However I think it should handled in Tokio as other users might depend on this flag. |
Yes, that's right.
I don't know TBH but I'll investigate. :-) |
I'm sure this should be closed yet. Yes the issue itself is resolved, but @bnoordhuis suggested we might be able to recover from this error. Maybe we should wait until he has had time to investigate further. |
I think Github automatically closed it. |
Yes, that's right.
I've been trying to investigate this but the application I'm working on has changed significantly enough that the original issue no longer appears and trying to mold it back to its previous incarnation was too much of a time sink. I'm good with closing this. |
Version
1.6.1 - issue appears to be present in ToT as well though
Platform
Linux bender 5.8.0-53-lowlatency #60-Ubuntu SMP PREEMPT Thu May 6 08:53:53 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Description
I regret that I don't have a small reproduction but it only pops up infrequently. The program does quite literally this:
Sporadically, this happens:
Note the
EPOLLOUT|EPOLLHUP
. If I read Tokio's source code right, it considers the presence ofEPOLLOUT
to mean success and ignores theEPOLLHUP
. The connecting process then proceeds to write but that fails as follows:My expectation is that
UnixStream::connect()
fails with an error whenEPOLLHUP
is set.The text was updated successfully, but these errors were encountered: