Skip to content

Commit

Permalink
Handle unexpected return values from epoll_wait.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan McMillion committed Jun 9, 2020
1 parent e50562e commit 0d3f24a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/device/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ impl<H: Sync + Send> EventPoll<H> {
/// handler.
pub fn wait(&self) -> WaitResult<'_, H> {
let mut event = epoll_event { events: 0, u64: 0 };
if unsafe { epoll_wait(self.epoll, &mut event, 1, -1) } == -1 {
return WaitResult::Error(errno_str());
match unsafe { epoll_wait(self.epoll, &mut event, 1, -1) } {
-1 => return WaitResult::Error(errno_str()),
1 => {}
_ => return WaitResult::Error("unexpected number of events returned".to_string()),
}

let event_data = unsafe { (event.u64 as *mut Event<H>).as_mut().unwrap() };
Expand Down

0 comments on commit 0d3f24a

Please sign in to comment.