Merge branch 'master' into refactor/restart_worker_test

This commit is contained in:
Rob Ede 2021-04-15 13:32:51 +01:00 committed by GitHub
commit edb40716a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -375,6 +375,12 @@ impl Default for WorkerState {
}
}
impl Drop for ServerWorker {
fn drop(&mut self) {
Arbiter::current().stop();
}
}
impl Future for ServerWorker {
type Output = ();
@ -458,14 +464,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.