From 3c1f57706ace5ea222ab7414bdebe67a862c9229 Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Thu, 15 Apr 2021 05:31:03 -0700 Subject: [PATCH] Make ServerWorker drop stop Arbiter it runs on (#334) --- actix-server/src/worker.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index cd7491d7..801467f8 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -368,6 +368,12 @@ impl Default for WorkerState { } } +impl Drop for ServerWorker { + fn drop(&mut self) { + Arbiter::current().stop(); + } +} + impl Future for ServerWorker { type Output = (); @@ -451,14 +457,12 @@ impl Future for ServerWorker { if let WorkerState::Shutdown(shutdown) = mem::take(&mut this.state) { let _ = shutdown.tx.send(true); } - Arbiter::current().stop(); Poll::Ready(()) } else if shutdown.start_from.elapsed() >= this.shutdown_timeout { // Timeout forceful shutdown. if let WorkerState::Shutdown(shutdown) = mem::take(&mut this.state) { let _ = shutdown.tx.send(false); } - Arbiter::current().stop(); Poll::Ready(()) } else { // Reset timer and wait for 1 second.