From: Christophe ThiƩry Date: Mon, 16 Jan 2012 10:47:16 +0000 (+0100) Subject: MSG_task_dsend: don't apply a default function if cleanup is NULL X-Git-Tag: exp_20120216~125^2~16^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/e045b97cdfe87a1f96a92fd26122fa4675667513 MSG_task_dsend: don't apply a default function if cleanup is NULL NULL now means that no cleanup function will be called by SIMIX. This is useful if the task is garbage collected (as in Lua). --- diff --git a/examples/msg/pmm/msg_pmm.c b/examples/msg/pmm/msg_pmm.c index 1ae9c6664e..0cdf4d930f 100644 --- a/examples/msg/pmm/msg_pmm.c +++ b/examples/msg/pmm/msg_pmm.c @@ -158,7 +158,7 @@ int node(int argc, char **argv) result->sC = xbt_matrix_new_sub(sC, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE, 0, 0, NULL); task = MSG_task_create("result",100,100,result); - MSG_task_dsend(task, "0", NULL); + MSG_task_dsend(task, "0", (void_f_pvoid_t) MSG_task_destroy); } /* Clean up and finish*/ diff --git a/src/msg/msg_gos.c b/src/msg/msg_gos.c index aa2ec0ddae..573f782cbb 100644 --- a/src/msg/msg_gos.c +++ b/src/msg/msg_gos.c @@ -435,8 +435,8 @@ XBT_INLINE msg_comm_t MSG_task_isend_with_matching(m_task_t task, const char *al * \param task a #m_task_t to send on another location. * \param alias name of the mailbox to sent the task to * \param cleanup a function to destroy the task if the - * communication fails (if NULL, MSG_task_destroy() will - * be used by default) + * communication fails, e.g. MSG_task_destroy + * (if NULL, no function will be called) */ void MSG_task_dsend(m_task_t task, const char *alias, void_f_pvoid_t cleanup) { @@ -446,10 +446,6 @@ void MSG_task_dsend(m_task_t task, const char *alias, void_f_pvoid_t cleanup) CHECK_HOST(); - if (cleanup == NULL) { - cleanup = (void_f_pvoid_t) MSG_task_destroy; - } - /* FIXME: these functions are not traceable */ /* Prepare the task to send */ @@ -465,7 +461,7 @@ void MSG_task_dsend(m_task_t task, const char *alias, void_f_pvoid_t cleanup) /* Send it by calling SIMIX network layer */ smx_action_t comm = SIMIX_req_comm_isend(mailbox, t_simdata->message_size, - t_simdata->rate, task, sizeof(void *), NULL,cleanup, NULL, 1); + t_simdata->rate, task, sizeof(void *), NULL, cleanup, NULL, 1); t_simdata->comm = comm; } diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 0ee16e8772..3e8e1aa5df 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -265,7 +265,9 @@ void SIMIX_comm_destroy(smx_action_t action) if (action->comm.detached && action->state != SIMIX_DONE) { /* the communication has failed and was detached: * we have to free the buffer */ - action->comm.clean_fun(action->comm.src_buff); + if (action->comm.clean_fun) { + action->comm.clean_fun(action->comm.src_buff); + } action->comm.src_buff = NULL; }