Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make SIMIX_req_comm(test/wait/testany/waitany) requests to destroy the comm actions.
[simgrid.git] / src / msg / gos.c
index 9ab4dc0..aefe0ec 100644 (file)
@@ -422,8 +422,11 @@ msg_comm_t MSG_task_isend(m_task_t task, const char *alias)
  *
  * \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)
  */
-void MSG_task_dsend(m_task_t task, const char *alias)
+void MSG_task_dsend(m_task_t task, const char *alias, void_f_pvoid_t cleanup)
 {
   simdata_task_t t_simdata = NULL;
   m_process_t process = MSG_process_self();
@@ -431,6 +434,10 @@ void MSG_task_dsend(m_task_t task, const char *alias)
 
   CHECK_HOST();
 
+  if (cleanup == NULL) {
+    cleanup = (void_f_pvoid_t) MSG_task_destroy;
+  }
+
   /* FIXME: these functions are not traceable */
 
   /* Prepare the task to send */
@@ -445,13 +452,8 @@ void MSG_task_dsend(m_task_t task, const char *alias)
   msg_global->sent_msg++;
 
   /* Send it by calling SIMIX network layer */
-  msg_comm_t comm = xbt_new0(s_msg_comm_t, 1);
-  comm->task_sent = task;
-  comm->task_received = NULL;
-  comm->status = MSG_OK;
-    SIMIX_req_comm_isend(mailbox, t_simdata->message_size,
-                         t_simdata->rate, task, sizeof(void *), NULL, NULL, 1);
-    /*t_simdata->comm = comm->s_comm;  FIXME: is the field t_simdata->comm still useful? */
+  SIMIX_req_comm_isend(mailbox, t_simdata->message_size,
+                       t_simdata->rate, task, sizeof(void *), NULL, cleanup, 1);
 }
 
 /** \ingroup msg_gos_functions
@@ -602,7 +604,7 @@ void MSG_comm_destroy(msg_comm_t comm)
   }
 
   /* FIXME auto-destroy comms from SIMIX to avoid this request */
-  SIMIX_req_comm_destroy(comm->s_comm);
+  /*SIMIX_req_comm_destroy(comm->s_comm);*/
   free(comm);
 }