Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
week-end cleanups in ActorImpl
[simgrid.git] / src / kernel / context / Context.cpp
index c28bf7b..5f754be 100644 (file)
@@ -86,14 +86,12 @@ void Context::stop()
 {
   actor_->finished_ = true;
 
-  if (actor_->auto_restart_ && actor_->host_->is_off()) {
-    XBT_DEBUG("Insert host %s to watched_hosts because it's off and %s needs to restart", actor_->host_->get_cname(),
-              actor_->get_cname());
-    watched_hosts.insert(actor_->host_->get_cname());
+  if (actor_->has_to_auto_restart() && not actor_->get_host()->is_on()) {
+    XBT_DEBUG("Insert host %s to watched_hosts because it's off and %s needs to restart",
+              actor_->get_host()->get_cname(), actor_->get_cname());
+    watched_hosts.insert(actor_->get_host()->get_name());
   }
 
-  actor_->finished_ = true;
-
   // Execute the termination callbacks
   smx_process_exit_status_t exit_status = (actor_->context_->iwannadie) ? SMX_EXIT_FAILURE : SMX_EXIT_SUCCESS;
   while (not actor_->on_exit.empty()) {
@@ -108,7 +106,7 @@ void Context::stop()
   actor_->comms.clear();
 
   XBT_DEBUG("%s@%s(%ld) should not run anymore", actor_->get_cname(), actor_->iface()->get_host()->get_cname(),
-            actor_->pid_);
+            actor_->get_pid());
 
   if (this->cleanup_func_)
     this->cleanup_func_(this->actor_);
@@ -116,6 +114,13 @@ void Context::stop()
   this->iwannadie = false; // don't let the simcall's yield() do a Context::stop(), because that's me
   simgrid::simix::simcall([this] {
     simgrid::s4u::Actor::on_destruction(actor_->iface());
+
+    /* Unregister from the kill timer if any */
+    if (actor_->kill_timer != nullptr) {
+      SIMIX_timer_remove(actor_->kill_timer);
+      actor_->kill_timer = nullptr;
+    }
+
     SIMIX_process_cleanup(actor_);
   });
   this->iwannadie = true;