A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
Lua: close the Lua world of a process being destroyed
[simgrid.git]
/
src
/
msg
/
msg_process.c
diff --git
a/src/msg/msg_process.c
b/src/msg/msg_process.c
index
5030416
..
931ec4e
100644
(file)
--- a/
src/msg/msg_process.c
+++ b/
src/msg/msg_process.c
@@
-35,6
+35,7
@@
void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc)
{
simdata_process_t msg_proc;
+ // get the MSG process from the SIMIX process
if (smx_proc == SIMIX_process_self()) {
/* avoid a SIMIX request if this function is called by the process itself */
msg_proc = SIMIX_process_self_get_data(smx_proc);
@@
-49,6
+50,12
@@
void MSG_process_cleanup_from_SIMIX(smx_process_t smx_proc)
TRACE_msg_process_end(smx_proc);
#endif
+ // free the data if a function was provided
+ if (msg_proc->data && msg_global->process_data_cleanup) {
+ msg_global->process_data_cleanup(msg_proc->data);
+ }
+
+ // free the MSG process
xbt_free(msg_proc);
}
@@
-263,6
+270,17
@@
MSG_error_t MSG_process_set_data(m_process_t process, void *data)
return MSG_OK;
}
+/** \ingroup m_process_management
+ * \brief Sets a cleanup function to be called to free the userdata of a
+ * process when a process is destroyed.
+ * \param data_cleanup a cleanup function for the userdata of a process,
+ * or NULL to call no function
+ */
+XBT_PUBLIC(void) MSG_process_set_data_cleanup(void_f_pvoid_t data_cleanup) {
+
+ msg_global->process_data_cleanup = data_cleanup;
+}
+
/** \ingroup m_process_management
* \brief Return the location on which an agent is running.
* \param process a process (NULL means the current one)