Add epoll integration for network sockets#4973
Add epoll integration for network sockets#4973WhySoBad wants to merge 13 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 comment has been minimized.
This comment has been minimized.
|
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 |
I prefer clean code over premature generalization. So unless we have at least a concrete idea for what other interest receivers there may be, I think it'd be less confusing to just hard-code for now that these are all blocked threads. |
|
Okay, so I'll change it that we just register thread id's together with an interest. |
|
Both are fine for me. |
I've now implemented it such that we always need to deregister the interests explicitly. |
1ee8f6c to
0a49628
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
I like it, very nice work. :) But I do of course have some comments. ;)
@rustbot author
|
|
||
| pub fn fulfills_interest(&self, interest: &BlockingIoInterest) -> bool { | ||
| match interest { | ||
| BlockingIoInterest::Read => self.readable || self.error, |
There was a problem hiding this comment.
Is there some documentation somewhere saying that "error" sources should be "ready" for reads and writes?
There was a problem hiding this comment.
For mio we have this: https://docs.rs/mio/latest/mio/struct.Poll.html#readiness-operations
Should I link this here?
There was a problem hiding this comment.
That does not say that read implies error. It says that read may imply error.
I guess this is actually mostly a decision for us -- should we wake up threads on an error signal? That probably makes sense, but then we should explain why.
This comment has been minimized.
This comment has been minimized.
ebd1e70 to
1da89ec
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. |
|
@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.