From db3385e8659ae17aa43fb27b8d119eda254c111c Mon Sep 17 00:00:00 2001 From: shuo Date: Thu, 4 Feb 2021 18:20:37 +0800 Subject: [PATCH] retry on EINTR in accept loop (#264) Co-authored-by: lishuo --- actix-server/CHANGES.md | 2 ++ actix-server/src/accept.rs | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/actix-server/CHANGES.md b/actix-server/CHANGES.md index 70728064..d99287ef 100644 --- a/actix-server/CHANGES.md +++ b/actix-server/CHANGES.md @@ -2,8 +2,10 @@ ## Unreleased - 2021-xx-xx * Hidden `ServerBuilder::start` method has been removed. Use `ServerBuilder::run`. [#246] +* Add retry for EINTR(`io::Interrupted`) in `Accept`'s poll loop. [#264] [#246]: https://github.com/actix/actix-net/pull/246 +[#264]: https://github.com/actix/actix-net/pull/264 ## 2.0.0-beta.2 - 2021-01-03 diff --git a/actix-server/src/accept.rs b/actix-server/src/accept.rs index a52184d9..c8c1da47 100644 --- a/actix-server/src/accept.rs +++ b/actix-server/src/accept.rs @@ -161,9 +161,16 @@ impl Accept { let mut events = mio::Events::with_capacity(128); loop { - self.poll - .poll(&mut events, None) - .unwrap_or_else(|e| panic!("Poll error: {}", e)); + if let Err(e) = self.poll.poll(&mut events, None) { + match e.kind() { + std::io::ErrorKind::Interrupted => { + continue; + } + _ => { + panic!("Poll error: {}", e); + } + } + } for event in events.iter() { let token = event.token();