From c112965cc1bb1726d51503a29f7883ddb00f4f46 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 2 Aug 2019 20:12:24 +0200 Subject: [PATCH] forcefully kill exiting actors even if their host is not off Without this, this_actor::exit() deadlocks on Thread factory because the actor does not exit soon enough to release maestro that is joining its thread. --- src/kernel/actor/ActorImpl.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 0db52ef1a3..c8640b4762 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -199,10 +199,6 @@ void ActorImpl::exit() suspended_ = false; exception_ = nullptr; - // Forcefully kill the actor if its host is turned off. Not a HostFailureException because you should not survive that - if (not host_->is_on()) - this->throw_exception(std::make_exception_ptr(ForcefulKillException("host failed"))); - /* destroy the blocking synchro if any */ if (waiting_synchro != nullptr) { waiting_synchro->cancel(); @@ -225,6 +221,9 @@ void ActorImpl::exit() waiting_synchro = nullptr; } + + // Forcefully kill the actor if its host is turned off. Not a HostFailureException because you should not survive that + this->throw_exception(std::make_exception_ptr(ForcefulKillException(host_->is_on() ? "exited" : "host failed"))); } void ActorImpl::kill(ActorImpl* actor) -- 2.20.1