Add epoll integration for network sockets#4973
Add epoll integration for network sockets#4973WhySoBad wants to merge 8 commits intorust-lang:masterfrom
Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
This comment has been minimized.
This comment has been minimized.
6d96f3e to
db7c84b
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Feedback was given IRL. |
|
Reminder, once the PR becomes ready for a review, use |
|
I noticed that I wrote the review comments of today's meeting in the PR on my fork, but every of those comments should now be resolved anyways. The Also, as you requested, the epoll test cases should now fail/block indefinitely when we forget to register a socket or when we forget to remove the readiness after receiving EWOULDBLOCK. @rustbot ready |
Hi,
This pull request adds integration for Miri's epoll shim to the TCP socket shim.
Due to the platform specific differences of mio's poll, the blocking I/O manager had to be refactored to a high degree. Instead of having sources only registered in the poll when we're currently interested in an event, we now have the sources registered in the poll with all available interests for their entire lifespan. We now also store the current readiness for every source in the blocking I/O manager.
When for example a thread should be blocked until some I/O interest is fulfilled on a source, we just add the receiver to the blocking I/O manager without changing anything in the poll itself. In every call to
pollwe now return all interest receivers whose interests are currently fulfilled -- no longer only those which are newly fulfilled.Once we hit an
EWOULDBLOCKin a source operation (e.g. read, write, accept, ...) we need to falsify the corresponding readiness in the blocking I/O manager to keep it up to date.With this refactor, the actual epoll implementation is pretty straightforward -- we just need to return the readiness stored in the blocking I/O manager from the
epoll_active_eventsmethod of host-backed source file descriptions.