From 4ccbacb51eb49323847a906c3e79ea838d76e2a7 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Tue, 7 Aug 2018 11:04:36 +0200 Subject: [PATCH] split a function in two and kill it --- src/s4u/s4u_Actor.cpp | 9 ++++++++- src/simix/ActorImpl.cpp | 10 +++++++--- src/simix/smx_host.cpp | 21 --------------------- src/simix/smx_host_private.hpp | 2 -- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index 2aef0dca9b..a5b89f6eb3 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -10,6 +10,7 @@ #include "src/kernel/activity/ExecImpl.hpp" #include "src/simix/smx_host_private.hpp" #include "src/simix/smx_private.hpp" +#include "src/surf/HostImpl.hpp" #include @@ -76,7 +77,13 @@ void Actor::set_auto_restart(bool autorestart) { simgrid::simix::simcall([this, autorestart]() { pimpl_->set_auto_restart(autorestart); - SIMIX_host_add_auto_restart_process(pimpl_->host_, pimpl_); + + std::map actors_map = pimpl_->host_->pimpl_->actors_at_boot_; + if (actors_map.find(pimpl_->name_) == actors_map.end()) { + simgrid::kernel::actor::ProcessArg* arg = new simgrid::kernel::actor::ProcessArg(pimpl_->host_, pimpl_); + XBT_DEBUG("Adding Process %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname()); + actors_map.insert({arg->name, arg}); + } }); } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 7ff3367903..8c60d57d16 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -700,10 +700,14 @@ void SIMIX_process_yield(smx_actor_t self) self->finished_ = true; /* execute the on_exit functions */ SIMIX_process_on_exit_runall(self); - /* Add the process to the list of process to restart, only if the host is down */ - if (self->auto_restart_ && self->host_->is_off()) { - SIMIX_host_add_auto_restart_process(self->host_, self); + + if (self->auto_restart_ && self->host_->is_off() && + watched_hosts.find(self->host_->get_cname()) == watched_hosts.end()) { + XBT_DEBUG("Push host %s to watched_hosts because it's off and %s needs to restart", self->host_->get_cname(), + self->get_cname()); + watched_hosts.insert(self->host_->get_cname()); } + XBT_DEBUG("Process %s@%s is dead", self->get_cname(), self->host_->get_cname()); self->context_->stop(); } diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index 3099554fe8..dc7f150213 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -24,27 +24,6 @@ const char* sg_host_self_get_name() return host->get_cname(); } -/** - * @brief Add a process to the list of the processes that the host will restart when it comes back - * This function add a process to the list of the processes that will be restarted when the host comes - * back. It is expected that this function is called when the host is down. - * The processes will only be restarted once, meaning that you will have to register the process - * again to restart the process again. - */ -void SIMIX_host_add_auto_restart_process(sg_host_t host, simgrid::kernel::actor::ActorImpl* actor) -{ - simgrid::kernel::actor::ProcessArg* arg = new simgrid::kernel::actor::ProcessArg(host, actor); - - if (host->is_off() && watched_hosts.find(host->get_cname()) == watched_hosts.end()) { - watched_hosts.insert(host->get_cname()); - XBT_DEBUG("Push host %s to watched_hosts because state == SURF_RESOURCE_OFF", host->get_cname()); - } - if (host->pimpl_->actors_at_boot_.find(actor->get_name()) == host->pimpl_->actors_at_boot_.end()) { - XBT_DEBUG("Adding Process %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname()); - host->pimpl_->actors_at_boot_.insert({arg->name, arg}); - } -} - simgrid::kernel::activity::ExecImplPtr SIMIX_execution_start(std::string name, std::string category, double flops_amount, double priority, double bound, sg_host_t host) diff --git a/src/simix/smx_host_private.hpp b/src/simix/smx_host_private.hpp index b02afbd51c..1a6da742c3 100644 --- a/src/simix/smx_host_private.hpp +++ b/src/simix/smx_host_private.hpp @@ -10,8 +10,6 @@ #include -XBT_PRIVATE void SIMIX_host_add_auto_restart_process(sg_host_t host, simgrid::kernel::actor::ActorImpl* actor); - XBT_PRIVATE void SIMIX_execution_finish(smx_activity_t synchro); XBT_PRIVATE void SIMIX_set_category(smx_activity_t synchro, std::string category); -- 2.20.1