diff --git a/ntex-server/src/net/accept.rs b/ntex-server/src/net/accept.rs index bcab6f7c..9349a26e 100644 --- a/ntex-server/src/net/accept.rs +++ b/ntex-server/src/net/accept.rs @@ -197,14 +197,13 @@ impl Accept { fn poll(&mut self) { log::trace!("Starting server accept loop"); - let _ = self.tx.take().unwrap().send(()); - // Create storage for events let mut events = Events::with_capacity(NonZeroUsize::new(512).unwrap()); + let mut timeout = Some(Duration::ZERO); loop { println!("------- ACCEPT LOOP"); - if let Err(e) = self.poller.wait(&mut events, None) { + if let Err(e) = self.poller.wait(&mut events, timeout) { println!("------- ACCEPT LOOP ERR: {:?}", e); if e.kind() == io::ErrorKind::Interrupted { continue; @@ -213,6 +212,11 @@ impl Accept { } } + if timeout.is_some() { + timeout = None; + let _ = self.tx.take().unwrap().send(()); + } + println!("------- ACCEPTING: {:?}", events.len()); for idx in 0..self.sockets.len() { if !self.sockets[idx].registered.get() {