-
Notifications
You must be signed in to change notification settings - Fork 749
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
poll()’s return on timeout not documented #1600
Comments
Yep, we try to provide an API similar to what to OS provides to reduce surprises (ironically introducing a surprise here).
I'm not sure about this. I don't know if any, let alone all, OSs require their poll calls to only return zero events in case of a timeout. What is your use case that you need to know whether or not the timeout is hit? |
I’m using this to implement an option to kill a process when it doesn’t provide output for a given amount of time. These are the two questions that I can’t answer based on the documentation (not asking you to answer them; just explaining my thinking):
So, the real issue is that the behavior is undefined. Of course, that’s somewhat hard to avoid when you’re abstracting a bunch of different implementations. I can do some research into how the underlying implementations handle timeouts and returns. I should be able to get to it by next Monday, August 8. |
Currently Mio doesn't do anything special here, so whatever the OS returns so do we. This currently means that no events means the timeout is hit.
I don't thing tracking the time is worth is for Mio in general. I think you're better of with assuming that no events means the timeout is hit.
It's unspecified, but yes. I think we can safely document that no events means the timeout is hit, but I don't know for sure.
👍 |
So, a few clarifications to start. I think there are ideally two things that the mio docs should answer:
TL;DR: 1.
|
I'm ok with documenting the current situation, but I don't think we can be this decisive. We're simply following what the OS does, so we can document that, but I don't think we can guarantee (or state in the docs) that It's think it would be better describe that currently all supported OSs return |
That’s not true, though. IOCP returns an error on timeout, and mio swallows that, returns It seems like a very bad idea to make code the uses |
Right, but that's to match the behaviour of Unix (kqueue and epoll). But neither kqueue or epoll guarantee that it can't timeout and return an events, even though they usually always return when an event is found. Note the keyword gurantee vs. 90% of the time here, like I said before I'm ok with documenting it in general.
Mio has many subtle difference we can't always smooth over, it's simply the nature of a low-level crate. We always do our best to document them though. |
What I’m proposing is documenting the current situation. What about just saying:
At core, that resolves the issue I have with this. As a consumer of the library, I need to know what mio does when it times out. |
And I agree with documenting the current situation, just not with guaranteeing it. That's the difference we're talking about. |
Ok, so what do you agree is the current situation? I just want to know so I (or somebody else, whatever) can submit a PR. |
The documentation for the poll() method doesn’t say what it returns when the timeout elapses. (It returns
Ok(())
.)I naively expected it to return something like
Err(std::io::Error::from(std::io::ErrorKind::TimedOut))
. I see that it behaves like theselect()
andpoll()
syscalls though, so maybe I shouldn’t have been surprised.It would be good to document this, including whether or not you can rely on the fact of the events collection being empty to indicate that it timed out.
The text was updated successfully, but these errors were encountered: