From 06f391e0227e27d00ccc07203024b30417eccf45 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 10 Dec 2020 14:22:26 +0000 Subject: [PATCH] tests: integration: Retry epoll if we receive -EINTR or -EAGAIN On the CI we are seeing that sometimes the epoll is receiving these errors which do not indicate a failure but that we should retry. Signed-off-by: Rob Bradford --- tests/integration.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 399764f8c..0d9ebc5e4 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -864,10 +864,20 @@ mod tests { ) .expect("Cannot add 'tcp_listener' event to epoll"); let mut events = vec![epoll::Event::new(epoll::Events::empty(), 0); 1]; - let num_events = epoll::wait(epoll_fd, timeout * 1000 as i32, &mut events[..]) - .map_err(Error::EpollWait)?; - if num_events == 0 { - return Err(Error::EpollWaitTimeout); + loop { + let num_events = + match epoll::wait(epoll_fd, timeout * 1000 as i32, &mut events[..]) { + Ok(num_events) => Ok(num_events), + Err(e) => match e.raw_os_error() { + Some(libc::EAGAIN) | Some(libc::EINTR) => continue, + _ => Err(e), + }, + } + .map_err(Error::EpollWait)?; + if num_events == 0 { + return Err(Error::EpollWaitTimeout); + } + break; } match listener.accept() {