Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MSG_task_dsend: don't apply a default function if cleanup is NULL
authorChristophe Thiéry <christopho128@gmail.com>
Mon, 16 Jan 2012 10:47:16 +0000 (11:47 +0100)
committerChristophe Thiéry <christopho128@gmail.com>
Mon, 16 Jan 2012 10:47:16 +0000 (11:47 +0100)
NULL now means that no cleanup function will be called by SIMIX.
This is useful if the task is garbage collected (as in Lua).

examples/msg/pmm/msg_pmm.c
src/msg/msg_gos.c
src/simix/smx_network.c

index 1ae9c66..0cdf4d9 100644 (file)
@@ -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*/
index aa2ec0d..573f782 100644 (file)
@@ -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;
 }
 
index 0ee16e8..3e8e1aa 100644 (file)
@@ -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;
   }