Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
finish the cleanup of the netcard list container
[simgrid.git] / src / s4u / s4u_host.cpp
index 254dba7..72c3dfc 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <unordered_map>
 
+#include "simgrid/s4u/engine.hpp"
 #include "simgrid/s4u/host.hpp"
 #include "simgrid/s4u/storage.hpp"
 #include "simgrid/simix.hpp"
@@ -43,7 +44,7 @@ simgrid::xbt::signal<void(Host&)> Host::onStateChange;
 Host::Host(const char* name)
   : name_(name)
 {
-  xbt_assert(sg_host_by_name(name) == nullptr, "Refusing to create a second host named '%s'.", name);
+  xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name);
   host_list[name_] = this;
 }
 
@@ -52,8 +53,9 @@ Host::~Host()
   xbt_assert(currentlyDestroying_, "Please call h->destroy() instead of manually deleting it.");
 
   delete pimpl_;
+  if (pimpl_netcard != nullptr) // not removed yet by a children class
+    simgrid::s4u::Engine::instance()->netcardUnregister(pimpl_netcard);
   delete pimpl_cpu;
-  delete pimpl_netcard;
   delete mounts;
 }
 
@@ -134,7 +136,7 @@ int Host::pstatesCount() const {
  */
 void Host::routeTo(Host* dest, std::vector<Link*>* links, double* latency)
 {
-  simgrid::kernel::routing::AsImpl::getGlobalRoute(pimpl_netcard, dest->pimpl_netcard, links, latency);
+  simgrid::kernel::routing::NetZoneImpl::getGlobalRoute(pimpl_netcard, dest->pimpl_netcard, links, latency);
   if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
     XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", cname(), dest->cname(),
                (latency == nullptr ? -1 : *latency));