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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2020-12-10 14:22:26 +00:00 committed by Bo Chen
parent 60d2469e7a
commit 06f391e022

View File

@ -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() {