1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 22:51:07 +01:00

Do not do double check on connection num when entering graceful shutdown (#309)

This commit is contained in:
fakeshadow 2021-04-02 04:49:12 -07:00 committed by GitHub
parent fdac52aa11
commit d8889c63ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);