Skip to content

Commit

Permalink
Retry poll on EINTR/EAGAIN instead of debug printing
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHabets committed Aug 31, 2024
1 parent dc8276a commit 0768a94
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/posix/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ fn wait_fd(fd: RawFd, events: PollFlags, timeout: Duration) -> io::Result<()> {
use nix::errno::Errno::{EIO, EPIPE};

let mut fd = PollFd::new(fd, events);

let wait = match poll_clamped(&mut fd, timeout) {
Ok(r) => r,
Err(e) => {
dbg!(e);
return Err(io::Error::from(crate::Error::from(e)));
}
};
let end = std::time::Instant::now() + timeout;
let wait;
loop {
wait = match poll_clamped(&mut fd, end - std::time::Instant::now()) {
Ok(r) => r,
Err(nix::Error::EINTR) => continue,
Err(nix::Error::EAGAIN) => continue,
Err(e) => {
dbg!(e);
return Err(io::Error::from(crate::Error::from(e)));
}
};
break;
}
// All errors generated by poll or ppoll are already caught by the nix wrapper around libc, so
// here we only need to check if there's at least 1 event
if wait != 1 {
Expand Down

0 comments on commit 0768a94

Please sign in to comment.