X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2f750aacf2dd98445821a7209980f6c354207a86..c112965cc1bb1726d51503a29f7883ddb00f4f46:/src/kernel/actor/ActorImpl.cpp diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index fc75399d82..c8640b4762 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -61,9 +61,13 @@ ActorImpl::ActorImpl(const simgrid::xbt::string& name, s4u::Host* host) : host_( ActorImpl::~ActorImpl() { - context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops - simgrid::simix::simcall([this] { simgrid::s4u::Actor::on_destruction(*ciface()); }); - context_->iwannadie = true; + if (simix_global != nullptr && this != simix_global->maestro_process) { + if (context_.get() != nullptr) /* the actor was not start()ed yet. This happens if its host was initially off */ + context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops + simgrid::simix::simcall([this] { simgrid::s4u::Actor::on_destruction(*ciface()); }); + if (context_.get() != nullptr) + context_->iwannadie = true; + } } /* Become an actor in the simulation @@ -183,6 +187,10 @@ void ActorImpl::cleanup() } simix_global->mutex.unlock(); + + context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops + simgrid::simix::simcall([this] { simgrid::s4u::Actor::on_termination(*ciface()); }); + context_->iwannadie = true; } void ActorImpl::exit() @@ -191,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(); @@ -217,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)