-
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
Do not hang in poll if event loop is destroyed #17
base: master
Are you sure you want to change the base?
Conversation
04ce3f7
to
c5e394e
Compare
3440120
to
2b2f615
Compare
Rebased against master. |
Thanks for the PR @stepancheg! This seems reasonable to try to get all connections and such to return an error ASAP as soon as the associated |
Are you sure this is going to work? If |
Ah yeah I figure it'd look like:
|
Which operation exactly should fall? Interest is registered inside |
Yes what I'm thinking is that the error in the |
I don't understand. That next "I/O" operation won't fall. Have a look at the implementation of
If we are talking about
and in callers of |
Ah so to clarify, |
Yes, it does. I don't full understand motivation behind this design decision (and it looks fragile to me), but anyway it seems to work. I've updated the patch to return |
src/reactor/mod.rs
Outdated
rx: Receiver<Message>, | ||
// `rx` is `Option` here only because it is needed to be dropped explicitly | ||
// in `drop` before other things. | ||
rx: Option<Receiver<Message>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using an Option
here, perhaps a method could be used instead? We end up using this as a custom type anyway.
src/reactor/mod.rs
Outdated
@@ -548,15 +566,15 @@ impl Remote { | |||
/// | |||
/// Note that while the closure, `F`, requires the `Send` bound as it might | |||
/// cross threads, the future `R` does not. | |||
pub fn spawn<F, R>(&self, f: F) | |||
pub fn spawn<F, R>(&self, f: F) -> io::Result<()> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add documentation here for why io::Result<()>
is returned? (e.g. what an error means)
src/reactor/poll_evented.rs
Outdated
@@ -107,7 +114,7 @@ impl<E> PollEvented<E> { | |||
/// The flag indicating that this stream is readable is unset and the | |||
/// current task is scheduled to receive a notification when the stream is | |||
/// then again readable. | |||
pub fn need_read(&self) { | |||
pub fn need_read(&self) -> io::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like above, can you add documentation here for why these functions return an error?
Added several comments about why functions return errors, and replaced |
Ok this seems reasonable to me. I'm gonna hold off on merging it just yet until we get closer to the 0.2 release (due to breaking changes), however. Does that sound ok? |
If channel is dropped, receiver may still return EOF, and if channel is alive, receiver produces an error.
Rebased against master. |
I'd be keen to see this in a release soon, if possible. It sounds like v0.2 is waiting for futures crate to stabilize, so can this go into the next v0.1 release? Any idea when that might be please? |
Certainly yeah we could and this sooner! Right now it's a breaking change so we can't land it but it should be possible to add new versions of these functions and deprecate the old! Would y'all be willing to work on a patch that does that? |
@stepancheg - This is your fix. (Thank you!) Are you happy to fix it up for release? |
Cannot do it right now, very busy with my new job. |
This commit is targeted at solving tokio-rs/tokio-core#12 and incorporates the solution from tokio-rs/tokio-core#17. Namely the `need_read` and `need_write` functions on `PollEvented` now return an error when the connected reactor has gone away and the task cannot be blocked. This will typically naturally translate to errors being returned by various connected I/O objects and should help tear down the world in a clean-ish fashion.
Partialfix for #12.Edit: updated a patch.
Loop
destructor marks all loop handles dead, so any furtherpoll
requests fail (they currently panic, but should probably return an error).Also
Loop
destructor unparks all tasks waiting for IO on self. It has no effect on tasks bound to self event loop, but tasks running on different executors callpoll
right afterwards, so theyimmediately fail instead of hanging.