-
Notifications
You must be signed in to change notification settings - Fork 197
Add a raw file descriptor context #471
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
Conversation
Why not use |
This would require the file descriptor being borrowed for the lifetime of the |
Hmmm, then maybe https://docs.rs/rustix/latest/rustix/io/epoll/struct.Epoll.html#impl-FromRawFd-for-Epoll%3COwning%3C%27context%2C%20T%3E%3E optionally wrapped with a ManuallyDrop if you can't actually own the fd? Or just ignore me, this is just a gut reaction flyby against RawFd anyway. :) |
At that point, a |
I'd say that's partially fair. OwnedFds (assuming correct construction) at least provide aliasing guarantees so you don't run into the ABA problem on drop (can't have two OwnedFds with the same FD).
100% agree there. I'm actually curious now: is the idea to use rustix epoll here? Why wouldn't you want OwnedFds? |
Yes, the idea is to port parts of our code to
We assume that we still have access to the I/O source, so losing access to the |
Ok, I think I get the issue. On this line, you would need to either pass in an OwnedFd or BorrowedFd. Using OwnedFd is infeasible b/c you would need to move the io handle out of the Async while waiting for completion. Similarly, BorrowedFd doesn't work b/c you need to be able to modify/delete epoll IOs outside of the Async's calling context (so the lifetimes won't work). If I got that right, then yeah, RawFd seems to be the way to go. |
Obsolete after #487 |
This PR adds an unsafe
Context
for using a raw file descriptor. It is unsafe to instantiate, assuring that users do not use it for shenanigans.