Skip to content

Commit

Permalink
for larger timeouts using a blocking method to wait for the event
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Feb 2, 2024
1 parent 9609508 commit 9608987
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,18 @@ async fn poll_fds(fds: &mut [PollFd]) -> Result<(), IoError> {

pub(crate) fn poll(fds: &mut [PollFd], timeout: i32) -> Result<(), IoError> {
if timeout >= 0 {
let timeout = if timeout > 0 {
Some(Duration::from_millis(timeout.try_into().unwrap()))
// for larger timeouts, we block on the async function
if timeout >= 5000 {
block_on(
poll_fds(fds),
Some(Duration::from_millis(timeout.try_into().unwrap())),
)
} else {
None
};

poll_on(poll_fds(fds), timeout)
poll_on(
poll_fds(fds),
Some(Duration::from_millis(timeout.try_into().unwrap())),
)
}
} else {
block_on(poll_fds(fds), None)
}
Expand Down

0 comments on commit 9608987

Please sign in to comment.