From 2f750aacf2dd98445821a7209980f6c354207a86 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 1 Aug 2019 22:44:06 +0200 Subject: [PATCH 1/1] Actor::by_pid: also search through the dead actors Finally, my trick works with it. MPI ranks are not garbage collected as soon as they end because the MPI instance keeps a reference on them. With this, by_pid() works properly, even on dead but not collected actors. But this only works until the trash is emptied, obviously. This seem to be enough for the test I wanted to get running, so I will not fix that point tonight. --- src/kernel/actor/ActorImpl.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index c31407c38c..fc75399d82 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -59,7 +59,8 @@ ActorImpl::ActorImpl(const simgrid::xbt::string& name, s4u::Host* host) : host_( simcall.issuer = this; } -ActorImpl::~ActorImpl() { +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; @@ -624,8 +625,14 @@ const std::vector& simgrid::simix::process_get_runnable() /** @brief Returns the process from PID. */ smx_actor_t SIMIX_process_from_PID(aid_t PID) { - auto actor = simix_global->process_list.find(PID); - return actor == simix_global->process_list.end() ? nullptr : actor->second; + auto item = simix_global->process_list.find(PID); + if (item == simix_global->process_list.end()) { + for (auto& a : simix_global->actors_to_destroy) + if (a.get_pid() == PID) + return &a; + return nullptr; // Not found, even in the trash + } + return item->second; } void SIMIX_process_on_exit(smx_actor_t actor, int_f_pvoid_pvoid_t fun, void* data) -- 2.20.1