Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix an issue when you registered a on_exit function on a process_create.
authorSamuel Lepetit <samuel.lepetit@inria.fr>
Mon, 25 Jun 2012 08:41:12 +0000 (10:41 +0200)
committerSamuel Lepetit <samuel.lepetit@inria.fr>
Mon, 25 Jun 2012 08:41:12 +0000 (10:41 +0200)
include/simgrid/simix.h
src/msg/msg_process.c
src/simix/smx_process.c

index 1dd29b9..f541a1b 100644 (file)
@@ -253,7 +253,7 @@ XBT_PUBLIC(smx_context_t) SIMIX_process_get_context(smx_process_t);
 XBT_PUBLIC(void) SIMIX_process_set_context(smx_process_t p,smx_context_t c);
 XBT_PUBLIC(int) SIMIX_process_has_pending_comms(smx_process_t process);
 XBT_PUBLIC(void) SIMIX_process_on_exit_runall(smx_process_t process);
-XBT_PUBLIC(void) SIMIX_process_on_exit(int_f_pvoid_t fun, void *data);
+XBT_PUBLIC(void) SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data);
 
 /****************************** Communication *********************************/
 XBT_PUBLIC(void) SIMIX_comm_set_copy_data_callback(void (*callback) (smx_action_t, void*, size_t));
index 8579928..a37cc6b 100644 (file)
@@ -171,9 +171,6 @@ m_process_t MSG_process_create_with_environment(const char *name,
 
   if (SIMIX_process_self()) {
     simdata->PPID = MSG_process_get_PID(MSG_process_self());
-    #ifdef HAVE_TRACING
-      MSG_process_on_exit((int_f_pvoid_t)TRACE_msg_process_kill,MSG_process_self());
-    #endif
   } else {
     simdata->PPID = -1;
   }
@@ -192,7 +189,11 @@ m_process_t MSG_process_create_with_environment(const char *name,
     xbt_free(simdata);
     return NULL;
   }
-
+  else {
+    #ifdef HAVE_TRACING
+    SIMIX_process_on_exit(process,(int_f_pvoid_t)TRACE_msg_process_kill,MSG_process_self());
+    #endif
+  }
   return process;
 }
 
@@ -485,5 +486,5 @@ smx_context_t MSG_process_get_smx_ctx(m_process_t process) {
  * You should use them to free the data used by your process.
  */
 void MSG_process_on_exit(int_f_pvoid_t fun, void *data) {
-  SIMIX_process_on_exit(fun,data);
+  SIMIX_process_on_exit(MSG_process_self(),fun,data);
 }
index 1d35e54..d04ff3d 100644 (file)
@@ -727,11 +727,11 @@ void SIMIX_process_on_exit_runall(smx_process_t process) {
     (exit_fun.fun)(exit_fun.arg);
   }
 }
-void SIMIX_process_on_exit(int_f_pvoid_t fun, void *data) {
-  smx_process_t process = SIMIX_process_self();
+void SIMIX_process_on_exit(smx_process_t process, int_f_pvoid_t fun, void *data) {
   xbt_assert(process, "current process not found: are you in maestro context ?");
 
   if (!process->on_exit) {
+    XBT_INFO("NEW : %p",process);
     process->on_exit = xbt_dynar_new(sizeof(s_smx_process_exit_fun_t), NULL);
   }