Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove comm from src_proc->comms and dst_proc->comms when finish it,
[simgrid.git] / src / simix / smx_network.c
index b1351cb..23600af 100644 (file)
@@ -267,6 +267,9 @@ smx_action_t SIMIX_comm_new(e_smx_comm_type_t type)
   /* set communication */
   act->comm.type = type;
   act->comm.refcount = 1;
+  act->comm.src_data=NULL;
+  act->comm.dst_data=NULL;
+
 
 #ifdef HAVE_LATENCY_BOUND_TRACKING
   //initialize with unknown value
@@ -302,7 +305,7 @@ void SIMIX_comm_destroy(smx_action_t action)
   }
   action->comm.refcount--;
   if (action->comm.refcount > 0)
-    return;
+      return;
   XBT_DEBUG("Really free communication %p; refcount is now %d", action,
             action->comm.refcount);
 
@@ -322,6 +325,9 @@ void SIMIX_comm_destroy(smx_action_t action)
     action->comm.src_buff = NULL;
   }
 
+  if(action->comm.rdv)
+    SIMIX_rdv_remove(action->comm.rdv, action);
+
   xbt_mallocator_release(simix_global->action_mallocator, action);
 }
 
@@ -494,7 +500,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
       }/*else{
          XBT_DEBUG("Not yet finished, we have to wait %d\n", xbt_fifo_size(rdv->comm_fifo));
          }*/
-     // other_action->comm.refcount--;
+      other_action->comm.refcount--;
       SIMIX_comm_destroy(this_action);
       --smx_total_comms; // this creation was a pure waste
     }
@@ -516,7 +522,7 @@ smx_action_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_rdv_t rdv,
       --smx_total_comms; // this creation was a pure waste
       other_action->state = SIMIX_READY;
       other_action->comm.type = SIMIX_COMM_READY;
-   //   other_action->comm.refcount--;
+      //other_action->comm.refcount--;
     }
     xbt_fifo_push(dst_proc->comms, other_action);
   }
@@ -871,6 +877,16 @@ void SIMIX_comm_finish(smx_action_t action)
 
     simcall->issuer->waiting_action = NULL;
     xbt_fifo_remove(simcall->issuer->comms, action);
+    if(action->comm.detached){
+      if(simcall->issuer == action->comm.src_proc){
+        if(action->comm.dst_proc)
+          xbt_fifo_remove(action->comm.dst_proc->comms, action);
+      }
+      if(simcall->issuer == action->comm.dst_proc){
+        if(action->comm.src_proc)
+          xbt_fifo_remove(action->comm.src_proc->comms, action);
+      }
+    }
     SIMIX_simcall_answer(simcall);
     destroy_count++;
   }