From af8875f6ab2543da34978d67ec8b479f3c555dd7 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 7 Mar 2018 15:52:05 -0800 Subject: [PATCH] sleep on accept socket error --- src/server/srv.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/server/srv.rs b/src/server/srv.rs index e802e4ef0..82080403e 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -618,6 +618,9 @@ fn start_accept_thread(sock: net::TcpListener, addr: net::SocketAddr, backlog: i // Create storage for events let mut events = mio::Events::with_capacity(128); + // Sleep on error + let sleep = Duration::from_millis(100); + let mut next = 0; loop { if let Err(err) = poll.poll(&mut events, None) { @@ -641,6 +644,8 @@ fn start_accept_thread(sock: net::TcpListener, addr: net::SocketAddr, backlog: i if err.kind() != io::ErrorKind::WouldBlock { error!("Error accepting connection: {:?}", err); } + // sleep after error + thread::sleep(sleep); break } }