X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d6d6922922724a7495eb66d9f35fb7085b7d23ba..919a006452206f935fe271499ab68eb8cf875854:/src/kernel/actor/ActorImpl.cpp diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 47b901ce5e..ef37508256 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -29,7 +29,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_actor, kernel, "Logging specific to Actor's * * @return The SIMIX process */ -smx_actor_t SIMIX_process_self() // XBT_ATTRIB_DEPRECATED_v333 +simgrid::kernel::actor::ActorImpl* SIMIX_process_self() // XBT_ATTRIB_DEPRECATED_v333 { return simgrid::kernel::actor::ActorImpl::self(); } @@ -48,7 +48,7 @@ unsigned long* get_maxpid_addr() { return &maxpid; } -ActorIDTrait::ActorIDTrait(std::string name, aid_t ppid) : name_(std::move(name)), pid_(maxpid++), ppid_(ppid) {} +ActorIDTrait::ActorIDTrait(const std::string& name, aid_t ppid) : name_(name), pid_(maxpid++), ppid_(ppid) {} ActorImpl* ActorImpl::self() { @@ -137,10 +137,12 @@ bool ActorImpl::is_maestro() const void ActorImpl::cleanup_from_kernel() { - xbt_assert(s4u::Actor::is_maestro(), "Cleanup_from_kernel called from '%s' on '%s'", ActorImpl::self()->get_cname(), - get_cname()); + xbt_assert(s4u::Actor::is_maestro(), "Cleanup_from_kernel must be called in maestro context"); auto* engine = EngineImpl::get_instance(); + if (engine->get_actor_by_pid(get_pid()) == nullptr) + return; // Already cleaned + engine->remove_actor(get_pid()); if (host_ && host_actor_list_hook.is_linked()) host_->get_impl()->remove_actor(this); @@ -154,6 +156,7 @@ void ActorImpl::cleanup_from_kernel() } undaemonize(); + s4u::Actor::on_termination(*get_ciface()); while (not mailboxes_.empty()) mailboxes_.back()->set_receiver(nullptr); @@ -191,8 +194,9 @@ void ActorImpl::cleanup_from_self() simcall_.timeout_cb_ = nullptr; } - set_wannadie(false); // don't let the simcall's yield() do a Context::stop(), to avoid infinite loops - actor::simcall_answered([this] { s4u::Actor::on_termination(*get_ciface()); }); + /* maybe the actor was killed during a simcall, reset its observer */ + simcall_.observer_ = nullptr; + set_wannadie(); }