From f48cc395ebecc84d865ab551a672d2a2358624e5 Mon Sep 17 00:00:00 2001 From: Samuel Lepetit Date: Mon, 25 Jun 2012 10:41:12 +0200 Subject: [PATCH] Fix an issue when you registered a on_exit function on a process_create. --- include/simgrid/simix.h | 2 +- src/msg/msg_process.c | 11 ++++++----- src/simix/smx_process.c | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 1dd29b9250..f541a1bb73 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -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)); diff --git a/src/msg/msg_process.c b/src/msg/msg_process.c index 85799288f8..a37cc6b0ce 100644 --- a/src/msg/msg_process.c +++ b/src/msg/msg_process.c @@ -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); } diff --git a/src/simix/smx_process.c b/src/simix/smx_process.c index 1d35e545bd..d04ff3d784 100644 --- a/src/simix/smx_process.c +++ b/src/simix/smx_process.c @@ -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); } -- 2.20.1