Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / s4u / s4u_Host.cpp
index a9a58c0..9aa141c 100644 (file)
@@ -100,12 +100,27 @@ void Host::turnOn()
   }
 }
 
+/** @brief Stop the host if it is on */
 void Host::turnOff()
 {
   if (isOn()) {
     smx_actor_t self = SIMIX_process_self();
     simgrid::simix::simcall([this, self] {
-      SIMIX_host_off(this, self);
+      simgrid::simix::Host* host = this->extension<simgrid::simix::Host>();
+
+      xbt_assert((host != nullptr), "Invalid parameters");
+
+      this->pimpl_cpu->turn_off();
+
+      /* Clean Simulator data */
+      if (not host->process_list.empty()) {
+        for (auto& process : host->process_list) {
+          SIMIX_process_kill(&process, self);
+          XBT_DEBUG("Killing %s@%s on behalf of %s which turned off that host.", process.get_cname(),
+                    process.host->get_cname(), self->get_cname());
+        }
+      }
+
       on_state_change(*this);
     });
   }
@@ -561,7 +576,7 @@ double sg_host_route_bandwidth(sg_host_t from, sg_host_t to)
   std::vector<simgrid::s4u::Link*> vlinks;
   from->routeTo(to, vlinks, nullptr);
   for (auto const& link : vlinks) {
-    double bandwidth = link->bandwidth();
+    double bandwidth = link->get_bandwidth();
     if (bandwidth < min_bandwidth || min_bandwidth < 0.0)
       min_bandwidth = bandwidth;
   }