-
Notifications
You must be signed in to change notification settings - Fork 115
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
PollEvented needs robust fd {de,re}registration #172
Comments
Related to tokio-rs/mio#361. Unfortunately, |
Thanks for the report! Currently it's an intentional design decision that If you're working with custom file descriptors though maybe |
Thanks for the info @alexcrichton! I did consider explicitly calling
This is exactly how I'm using |
I think that Also yeah if you're working with dup'd file descriptors I think that file descriptions are associated with epoll (not descriptors), so closing a dup'd handle wouldn't auto-unregister. |
Ah the classic I'll take out the superfluous dup-ing from my code, but do you think it is still worth having |
Took a closer look at the internals of event registration in I'm good with ensuring a call to |
@alexcrichton yes, I completely forgot about the |
PollEvented
does not explicitlyderegister
itsio
source on drop, which can lead to problems with registering reused file descriptors.I found a situation in my project where a descriptor was duplicated, registered with the event loop via
PollEvented
, and then dropped after some work was done. A little bit later, a file descriptor was opened and happened to coincide with the same fd that was registered before. Upon registration of the "new" fd viaPollEvented
,EEXISTS
was returned byepoll_ctl(EPOLL_CTL_ADD)
(whose propagation effectively cancelled my future). Haven't noticed this happening on macOS which relies on kqueue (I believe its API is more forgiving of reregistration of existing fds).Seems like if
PollEvented
or theCore
loop could ensure sources are deregistered on drop it would solve the most amount of problems (though theRemote
toHandle
coersion could cause issues). AlternativelyEEXISTS
could be caught and retried viareregister
but I'm not sure if that would end up masking other significant problems.The text was updated successfully, but these errors were encountered: