diff options
author | Joe Wilm <joe@jwilm.com> | 2017-01-06 08:21:00 -0800 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2017-01-06 08:25:40 -0800 |
commit | 5f6dedd7d3056dd7d282dc6e50a61d8bf036bb9a (patch) | |
tree | bfebf6c8683aae6c10c0c769e9da8bc459aa43a3 /src | |
parent | 0bf19d2d6704c7651b1cd2e7152b2455a61edfc8 (diff) |
Handle EINTR in I/O loop
This fixes an issue where encountering some signals panicked the event
loop thread.
Resolves #76
Diffstat (limited to 'src')
-rw-r--r-- | src/event_loop.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/event_loop.rs b/src/event_loop.rs index d1c52367..eb0b24b8 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -222,6 +222,7 @@ impl<Io> EventLoop<Io> }, Err(err) => { match err.kind() { + ErrorKind::Interrupted | ErrorKind::WouldBlock => break, _ => panic!("unexpected read err: {:?}", err), } @@ -251,6 +252,7 @@ impl<Io> EventLoop<Io> Err(err) => { state.set_current(Some(current)); match err.kind() { + ErrorKind::Interrupted | ErrorKind::WouldBlock => break 'write_many, // TODO _ => panic!("unexpected err: {:?}", err), @@ -289,7 +291,12 @@ impl<Io> EventLoop<Io> }; 'event_loop: loop { - self.poll.poll(&mut events, None).expect("poll ok"); + if let Err(err) = self.poll.poll(&mut events, None) { + match err.kind() { + ErrorKind::Interrupted => continue, + _ => panic!("EventLoop polling error: {:?}", err) + } + } for event in events.iter() { match event.token() { |