From 960898759c94b864b0dc7643eee676cd276fb377 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Fri, 2 Feb 2024 11:05:08 +0100 Subject: [PATCH] for larger timeouts using a blocking method to wait for the event --- src/fd/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/fd/mod.rs b/src/fd/mod.rs index 6e0c04a50b..87847cf2c9 100644 --- a/src/fd/mod.rs +++ b/src/fd/mod.rs @@ -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) }