1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-27 18:02:58 +01:00

Make ServerWorker drop stop Arbiter it runs on (#334)

This commit is contained in:
fakeshadow 2021-04-15 05:31:03 -07:00 committed by GitHub
parent d49ecf7203
commit 3c1f57706a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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.