From 49f5c335f693fb49dcc9bc052a7e469f66fa9b59 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 11 Mar 2018 16:52:20 -0700 Subject: [PATCH] better sleep on error --- CHANGES.md | 2 ++ src/server/srv.rs | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 75a29d5d3..a1e2ed490 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,8 @@ * Fix steraming response handling for http/2 +* Better sleep on error support + ## 0.4.6 (2018-03-10) diff --git a/src/server/srv.rs b/src/server/srv.rs index c578331b6..8ba058b38 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -741,10 +741,9 @@ fn start_accept_thread( break } }, - Err(err) => { - if err.kind() != io::ErrorKind::WouldBlock { - error!("Error accepting connection: {:?}", err); - } + Err(ref e) if connection_error(e) => continue, + Err(e) => { + error!("Error accepting connection: {:?}", e); // sleep after error thread::sleep(sleep); break @@ -818,3 +817,16 @@ fn create_tcp_listener(addr: net::SocketAddr, backlog: i32) -> io::Result bool { + e.kind() == io::ErrorKind::ConnectionRefused || + e.kind() == io::ErrorKind::ConnectionAborted || + e.kind() == io::ErrorKind::ConnectionReset +}