Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Uncomment code, and fix meomry leaks in WorkstationVMHL13.
[simgrid.git] / src / surf / vm_workstation_hl13.cpp
index 66b3c6a..d9299c0 100644 (file)
@@ -1,9 +1,9 @@
-/*
- * vm_workstation.cpp
- *
- *  Created on: Nov 12, 2013
- *      Author: bedaride
- */
+/* Copyright (c) 2013-2014. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 #include "vm_workstation_hl13.hpp"
 #include "cpu_cas01.hpp"
 
@@ -297,10 +297,10 @@ WorkstationVMHL13::WorkstationVMHL13(WorkstationVMModelPtr model, const char* na
 WorkstationVMHL13::~WorkstationVMHL13()
 {
   /* ind_phys_workstation equals to smx_host_t */
-  // surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
+  surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
 
   /* Before clearing the entries in host_lib, we have to pick up resources. */
-  // CpuCas01Ptr cpu = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(ind_vm_workstation));
+  CpuCas01Ptr cpu = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(ind_vm_workstation));
 
   /* We deregister objects from host_lib, without invoking the freeing callback
    * of each level.
@@ -321,15 +321,15 @@ WorkstationVMHL13::~WorkstationVMHL13()
   xbt_assert(ret == 1, "Bug: some resource still remains");
 
   /* Free the cpu resource of the VM. If using power_trace, we will have to */
-  //delete cpu;
+  delete cpu;
 
   /* Free the network resource of the VM. */
-       // Nothing has to be done, because net_elmts is just a pointer on the physical one
+  // Nothing has to be done, because net_elmts is just a pointer on the physical one
 
   /* Free the storage resource of the VM. */
   // Not relevant yet
 
-       /* Free the workstation resource of the VM. */
+  /* Free the workstation resource of the VM. */
 }
 
 void WorkstationVMHL13::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {
@@ -432,9 +432,6 @@ void WorkstationVMHL13::migrate(surf_resource_t ind_dst_pm)
      if (p_action->getRemainsNoUpdate() > 0)
        XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->getRemainsNoUpdate());
 
-     int ret = p_action->unref();
-     xbt_assert(ret == 1, "Bug: some resource still remains");
-
      /* keep the bound value of the cpu action of the VM. */
      double old_bound = p_action->getBound();
      if (old_bound != 0) {
@@ -442,6 +439,9 @@ void WorkstationVMHL13::migrate(surf_resource_t ind_dst_pm)
        new_cpu_action->setBound(old_bound);
      }
 
+     int ret = p_action->unref();
+     xbt_assert(ret == 1, "Bug: some resource still remains");
+
      p_action = new_cpu_action;
    }