Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
forcefully kill exiting actors even if their host is not off
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 2 Aug 2019 18:12:24 +0000 (20:12 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 2 Aug 2019 18:12:29 +0000 (20:12 +0200)
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

index 0db52ef..c8640b4 100644 (file)
@@ -199,10 +199,6 @@ void ActorImpl::exit()
   suspended_          = false;
   exception_          = nullptr;
 
   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();
   /* destroy the blocking synchro if any */
   if (waiting_synchro != nullptr) {
     waiting_synchro->cancel();
@@ -225,6 +221,9 @@ void ActorImpl::exit()
 
     waiting_synchro = nullptr;
   }
 
     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)
 }
 
 void ActorImpl::kill(ActorImpl* actor)