Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MSG_comm_destroy should not assume that the task still exists
authorChristophe Thiéry <christopho128@gmail.com>
Fri, 13 Jan 2012 14:07:08 +0000 (15:07 +0100)
committerChristophe Thiéry <christopho128@gmail.com>
Fri, 13 Jan 2012 15:45:48 +0000 (16:45 +0100)
task->isused is reset when a comm finishes.
It's just MSG_comm_waitany who forgot to do it.

src/bindings/lua/lua_task.c
src/bindings/lua/simgrid_lua.c
src/msg/msg_gos.c

index 0305642..7512890 100644 (file)
@@ -205,7 +205,8 @@ static void task_copy_callback(m_task_t task, m_process_t src_process,
   sglua_copy_value(src, dst);
                                   /* src: ... task
                                      dst: ... task */
-  sglua_task_register(dst);             /* dst: ... */
+  sglua_task_register(dst);
+                                  /* dst: ... */
 
   /* the receiver is now the owner of the task and may destroy it:
    * make the sender forget the C task so that it doesn't garbage */
index b4b3763..2df56d5 100644 (file)
@@ -204,7 +204,6 @@ static int msg_register_platform(lua_State * L)
 /*
  * Register platform for Simdag
  */
-
 static int sd_register_platform(lua_State * L)
 {
   //surf_parse = console_parse_platform_wsL07;
index 9b60866..ad96462 100644 (file)
@@ -8,6 +8,7 @@
 #include "mc/mc.h"
 #include "xbt/log.h"
 #include "xbt/sysdep.h"
+#include "simix/private.h" // FIXME
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(msg_gos, msg,
                                 "Logging specific to MSG (gos)");
@@ -620,12 +621,6 @@ int MSG_comm_testany(xbt_dynar_t comms)
  */
 void MSG_comm_destroy(msg_comm_t comm)
 {
-  if (comm->task_received != NULL
-      && *comm->task_received != NULL
-      && MSG_comm_get_status(comm) == MSG_OK) {
-    (*comm->task_received)->simdata->isused = 0;
-  }
-
   xbt_free(comm);
 }
 
@@ -739,6 +734,11 @@ int MSG_comm_waitany(xbt_dynar_t comms)
   /* the communication is finished */
   comm->status = status;
 
+  if (comm->task_received != NULL) {
+    /* I am the receiver */
+    (*comm->task_received)->simdata->isused = 0;
+  }
+
   return finished_index;
 }