Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tweak the documentation rendering
[simgrid.git] / src / simix / smx_network.cpp
index bec9527..c4e1464 100644 (file)
@@ -155,7 +155,7 @@ static smx_synchro_t _find_matching_comm(std::deque<smx_synchro_t> *deque, e_smx
 /******************************************************************************/
 /*                          Communication synchros                            */
 /******************************************************************************/
-void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t src, smx_mailbox_t mbox,
+XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t src, smx_mailbox_t mbox,
                                   double task_size, double rate,
                                   void *src_buff, size_t src_buff_size,
                                   int (*match_fun)(void *, void *,smx_synchro_t),
@@ -167,7 +167,7 @@ void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_process_t src, smx_mai
   SIMCALL_SET_MC_VALUE(simcall, 0);
   simcall_HANDLER_comm_wait(simcall, comm, timeout);
 }
-smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t src_proc, smx_mailbox_t mbox,
+XBT_PRIVATE smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t src_proc, smx_mailbox_t mbox,
                                   double task_size, double rate,
                                   void *src_buff, size_t src_buff_size,
                                   int (*match_fun)(void *, void *,smx_synchro_t),
@@ -215,11 +215,9 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
   }
   xbt_fifo_push(src_proc->comms, other_synchro);
 
-  /* if the communication synchro is detached then decrease the refcount
-   * by one, so it will be eliminated by the receiver's destroy call */
+
   if (detached) {
     other_comm->detached = true;
-    other_comm->ref();
     other_comm->clean_fun = clean_fun;
   } else {
     other_comm->clean_fun = NULL;
@@ -246,7 +244,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
   return (detached ? NULL : other_comm);
 }
 
-void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_process_t receiver, smx_mailbox_t mbox,
+XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_process_t receiver, smx_mailbox_t mbox,
                          void *dst_buff, size_t *dst_buff_size,
                          int (*match_fun)(void *, void *, smx_synchro_t),
                          void (*copy_data_fun)(smx_synchro_t, void*, size_t),
@@ -257,7 +255,7 @@ void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_process_t receiver, sm
   simcall_HANDLER_comm_wait(simcall, comm, timeout);
 }
 
-smx_synchro_t simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_process_t receiver, smx_mailbox_t mbox,
+XBT_PRIVATE smx_synchro_t simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_process_t receiver, smx_mailbox_t mbox,
     void *dst_buff, size_t *dst_buff_size,
     int (*match_fun)(void *, void *, smx_synchro_t),
     void (*copy_data_fun)(smx_synchro_t, void*, size_t),
@@ -683,6 +681,8 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
       if(simcall->issuer == comm->dst_proc){
         if(comm->src_proc)
           xbt_fifo_remove(comm->src_proc->comms, synchro);
+        //in case of a detached comm we have an extra ref to remove, as the sender won't do it
+        destroy_count++;
       }
     }
     SIMIX_simcall_answer(simcall);
@@ -693,44 +693,6 @@ void SIMIX_comm_finish(smx_synchro_t synchro)
     static_cast<simgrid::simix::Comm*>(synchro)->unref();
 }
 
-/**
- * \brief This function is called when a Surf communication synchro is finished.
- * \param synchro the corresponding Simix communication
- */
-void SIMIX_post_comm(smx_synchro_t synchro)
-{
-  simgrid::simix::Comm *comm = static_cast<simgrid::simix::Comm*>(synchro);
-
-  /* Update synchro state */
-  if (comm->src_timeout &&
-      comm->src_timeout->getState() == simgrid::surf::Action::State::done)
-    synchro->state = SIMIX_SRC_TIMEOUT;
-  else if (comm->dst_timeout &&
-    comm->dst_timeout->getState() == simgrid::surf::Action::State::done)
-    synchro->state = SIMIX_DST_TIMEOUT;
-  else if (comm->src_timeout &&
-    comm->src_timeout->getState() == simgrid::surf::Action::State::failed)
-    synchro->state = SIMIX_SRC_HOST_FAILURE;
-  else if (comm->dst_timeout &&
-      comm->dst_timeout->getState() == simgrid::surf::Action::State::failed)
-    synchro->state = SIMIX_DST_HOST_FAILURE;
-  else if (comm->surf_comm &&
-    comm->surf_comm->getState() == simgrid::surf::Action::State::failed) {
-    synchro->state = SIMIX_LINK_FAILURE;
-  } else
-    synchro->state = SIMIX_DONE;
-
-  XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d",
-            comm, (int)comm->state, comm->src_proc, comm->dst_proc, comm->detached);
-
-  /* destroy the surf actions associated with the Simix communication */
-  comm->cleanupSurf();
-
-  /* if there are simcalls associated with the synchro, then answer them */
-  if (xbt_fifo_size(synchro->simcalls))
-    SIMIX_comm_finish(comm);
-}
-
 /******************************************************************************/
 /*                    SIMIX_comm_copy_data callbacks                       */
 /******************************************************************************/