X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f9521627fe1cef73bb8eccd5b11735dcbd906dbd..c112965cc1bb1726d51503a29f7883ddb00f4f46:/src/kernel/actor/ActorImpl.cpp diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 992ab56b37..c8640b4762 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -61,10 +61,12 @@ ActorImpl::ActorImpl(const simgrid::xbt::string& name, s4u::Host* host) : host_( ActorImpl::~ActorImpl() { - if (this != simix_global->maestro_process) { - context_->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops + 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()); }); - context_->iwannadie = true; + if (context_.get() != nullptr) + context_->iwannadie = true; } } @@ -197,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(); @@ -223,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)