Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Correctly destroy the MSG_host object of a VM
authorTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 28 Feb 2013 13:25:00 +0000 (14:25 +0100)
committerTakahiro Hirofuchi <t.hirofuchi+sg@aist.go.jp>
Thu, 28 Feb 2013 13:25:00 +0000 (14:25 +0100)
include/msg/msg.h
src/bindings/lua/lua_host.c
src/msg/msg_global.c
src/msg/msg_host.c
src/msg/msg_private.h
src/msg/msg_vm.c

index a739ece..6584b88 100644 (file)
@@ -95,7 +95,8 @@ XBT_PUBLIC(int) MSG_get_host_msgload(msg_host_t host);
 /* int MSG_get_msgload(void); This function lacks specification; discard it */
 XBT_PUBLIC(double) MSG_get_host_speed(msg_host_t h);
 XBT_PUBLIC(int) MSG_host_is_avail(msg_host_t h);
-XBT_PUBLIC(void) __MSG_host_destroy(msg_host_priv_t host);
+XBT_PUBLIC(void) __MSG_host_priv_free(msg_host_priv_t priv);
+XBT_PUBLIC(void) __MSG_host_destroy(msg_host_t host);
 
 /*property handlers*/
 XBT_PUBLIC(xbt_dict_t) MSG_host_get_properties(msg_host_t host);
index a862a2a..46d9086 100644 (file)
@@ -184,7 +184,7 @@ static int l_host_sleep(lua_State *L)
 static int l_host_destroy(lua_State *L)
 {
   msg_host_t ht = sglua_check_host(L, 1);
-  __MSG_host_destroy(MSG_host_priv(ht));
+  __MSG_host_priv_free(MSG_host_priv(ht));
   return 0;
 }
 
index f28d3e6..7290f94 100644 (file)
@@ -68,7 +68,7 @@ void MSG_init_nocheck(int *argc, char **argv) {
 #endif
 
   XBT_DEBUG("ADD MSG LEVELS");
-  MSG_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __MSG_host_destroy);
+  MSG_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __MSG_host_priv_free);
 
   atexit(MSG_exit);
 }
index 5a0de0d..52b25ae 100644 (file)
@@ -112,21 +112,30 @@ msg_host_t MSG_host_self(void)
 }
 
 /*
- * \brief Destroys a host (internal call only)
+ * \brief Frees private data of a host (internal call only)
  */
-void __MSG_host_destroy(msg_host_priv_t host) {
-
+void __MSG_host_priv_free(msg_host_priv_t priv)
+{
 #ifdef MSG_USE_DEPRECATED
   if (msg_global->max_channel > 0)
-    free(host->mailboxes);
+    free(priv->mailboxes);
 #endif
 
+  free(priv);
+}
+
+/*
+ * \brief Destroys a host (internal call only)
+ */
+void __MSG_host_destroy(msg_host_t host)
+{
+  const char *name = MSG_host_get_name(host);
   /* TODO:
    * What happens if VMs still remain on this host?
    * Revisit here after the surf layer gets stable.
    **/
 
-  free(host);
+  xbt_lib_unset(host_lib, name, MSG_HOST_LEVEL, 1);
 }
 
 /** \ingroup m_host_management
index a83c36c..e80ea65 100644 (file)
@@ -120,7 +120,7 @@ XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
 #endif
 
 msg_host_t __MSG_host_create(smx_host_t workstation);
-void __MSG_host_destroy(msg_host_priv_t host);
+void __MSG_host_destroy(msg_host_t host);
 
 void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc);
 void MSG_process_create_from_SIMIX(smx_process_t *process, const char *name,
index 33ece79..77c2da7 100644 (file)
@@ -378,6 +378,8 @@ void MSG_vm_destroy(msg_vm_t vm)
   /* Then, destroy the VM object */
   simcall_vm_destroy(vm);
 
+  __MSG_host_destroy(vm);
+
   #ifdef HAVE_TRACING
   TRACE_msg_vm_end(vm);
   #endif