Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add token_ring example.
[simgrid.git] / src / simix / smx_network.c
index d1c83d3..bc09a3e 100644 (file)
@@ -219,6 +219,9 @@ void SIMIX_comm_destroy(smx_action_t action)
 
   SIMIX_comm_destroy_internal_actions(action);
 
+  if(action->comm.detached)
+    ((void_f_pvoid_t)action->comm.src_data)(action->comm.src_buff);
+
   xbt_free(action);
 }
 
@@ -246,7 +249,8 @@ void SIMIX_comm_destroy_internal_actions(smx_action_t action)
 smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
                               double task_size, double rate,
                               void *src_buff, size_t src_buff_size,
-                              int (*match_fun)(void *, void *), void *data)
+                              int (*match_fun)(void *, void *), void *data,
+                              int detached)
 {
   smx_action_t action;
 
@@ -262,6 +266,13 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv,
     action->comm.type = SIMIX_COMM_READY;
   }
 
+  /* If the communication action is detached then decrease the refcount
+   * by one, so it will be eliminated by the receivers destroy call */
+  if(detached){
+    action->comm.detached = 1;
+    action->comm.refcount--;
+  }
+
   /* Setup the communication request */
   action->comm.src_proc = src_proc;
   action->comm.task_size = task_size;