Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change the prototype of copy data callbacks to add the source buffer
[simgrid.git] / src / msg / msg_gos.c
index 9b60866..aa2ec0d 100644 (file)
@@ -620,12 +620,6 @@ int MSG_comm_testany(xbt_dynar_t comms)
  */
 void MSG_comm_destroy(msg_comm_t comm)
 {
-  if (comm->task_received != NULL
-      && *comm->task_received != NULL
-      && MSG_comm_get_status(comm) == MSG_OK) {
-    (*comm->task_received)->simdata->isused = 0;
-  }
-
   xbt_free(comm);
 }
 
@@ -739,6 +733,11 @@ int MSG_comm_waitany(xbt_dynar_t comms)
   /* the communication is finished */
   comm->status = status;
 
+  if (comm->task_received != NULL) {
+    /* I am the receiver */
+    (*comm->task_received)->simdata->isused = 0;
+  }
+
   return finished_index;
 }
 
@@ -764,16 +763,18 @@ m_task_t MSG_comm_get_task(msg_comm_t comm)
 /**
  * \brief This function is called by SIMIX to copy the data of a comm.
  * \param comm the comm
+ * \param buff the data copied
  * \param buff_size size of the buffer
  */
-void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, size_t buff_size) {
+void MSG_comm_copy_data_from_SIMIX(smx_action_t comm, void* buff, size_t buff_size) {
 
   // copy the task
-  SIMIX_comm_copy_pointer_callback(comm, buff_size);
+  SIMIX_comm_copy_pointer_callback(comm, buff, buff_size);
 
   // notify the user callback if any
   if (msg_global->task_copy_callback) {
-    msg_global->task_copy_callback(SIMIX_req_comm_get_src_data(comm),
+    m_task_t task = buff;
+    msg_global->task_copy_callback(task,
         SIMIX_req_comm_get_src_proc(comm), SIMIX_req_comm_get_dst_proc(comm));
   }
 }