Skip to content

Commit

Permalink
improve compatibility to the BSD socket layer
Browse files Browse the repository at this point in the history
`poll` should return 0, if the system call timed out
  • Loading branch information
stlankes committed Feb 29, 2024
1 parent 1d7d019 commit d0e44de
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,17 @@ async fn poll_fds(fds: &mut [PollFd]) -> Result<u64, IoError> {
/// monitored is specified in the `fds` argument, which is an array
/// of structs of `PollFd`.
pub fn poll(fds: &mut [PollFd], timeout: Option<Duration>) -> Result<u64, IoError> {
block_on(poll_fds(fds), timeout)
let result = block_on(poll_fds(fds), timeout);
if let Err(ref e) = result {
if timeout.is_some() {
// A return value of zero indicates that the system call timed out
if *e == IoError::EAGAIN {
return Ok(0);
}
}
}

result
}

/// `eventfd` creates an linux-like "eventfd object" that can be used
Expand Down

0 comments on commit d0e44de

Please sign in to comment.