From d8889c63ef13b5be584cb99f557ff6072de57875 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Fri, 2 Apr 2021 04:49:12 -0700 Subject: [PATCH] Do not do double check on connection num when entering graceful shutdown (#309) --- actix-server/src/worker.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index e9b609f4..5e843983 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -353,18 +353,12 @@ impl Future for ServerWorker { return Poll::Ready(()); } else if graceful { self.shutdown(false); - let num = num_connections(); - if num != 0 { - info!("Graceful worker shutdown, {} connections", num); - self.state = WorkerState::Shutdown( - Box::pin(sleep(Duration::from_secs(1))), - Box::pin(sleep(self.config.shutdown_timeout)), - Some(result), - ); - } else { - let _ = result.send(true); - return Poll::Ready(()); - } + info!("Graceful worker shutdown, {} connections", num); + self.state = WorkerState::Shutdown( + Box::pin(sleep(Duration::from_secs(1))), + Box::pin(sleep(self.config.shutdown_timeout)), + Some(result), + ); } else { info!("Force shutdown worker, {} connections", num); self.shutdown(true);