Skip to content

Commit 92a8971

Browse files
committed
Handle EINTR to avoid crashing tests when debugging
When running tests with a debugger on Linux, Mio's poll function may return EINTR (interrupted system call) after halting on breakpoints, which causes the test to panic. The documentation for std::io::ErrorKind::Interrupted states that "interrupted operations can typically be retried." This commit adds a conditional to ignore this specific error and continue polling.
1 parent 17936cc commit 92a8971

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tests/tlsserver.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,13 @@ pub fn run_with_config(mut listener: TcpListener, config: rustls::ServerConfig)
385385

386386
let mut events = mio::Events::with_capacity(256);
387387
loop {
388-
poll.poll(&mut events, None).unwrap();
388+
if let Err(e) = poll.poll(&mut events, None) {
389+
if e.kind() == std::io::ErrorKind::Interrupted {
390+
log::debug!("I/O error {:?}", e);
391+
continue;
392+
}
393+
panic!("I/O error {:?}", e);
394+
}
389395

390396
for event in events.iter() {
391397
match event.token() {

0 commit comments

Comments
 (0)