Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix MC with the class-hierarchification of simgrid::simix::Synchro
[simgrid.git] / src / simix / smx_network.cpp
index 40144d4..51a5ab7 100644 (file)
@@ -137,7 +137,7 @@ static smx_synchro_t _find_matching_comm(std::deque<smx_synchro_t> *deque, e_smx
       XBT_DEBUG("Found a matching communication synchro %p", comm);
       if (remove_matching)
         deque->erase(it);
-      comm->refcount++;
+      comm->ref();
 #if HAVE_MC
       comm->mbox_cpy = comm->mbox;
 #endif
@@ -197,7 +197,7 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
       //this mailbox is for small messages, which have to be sent right now
       other_synchro->state = SIMIX_READY;
       other_comm->dst_proc=mbox->permanent_receiver;
-      other_comm->refcount++;
+      other_comm->ref();
       mbox->done_comm_queue->push_back(other_synchro);
       other_comm->mbox=mbox;
       XBT_DEBUG("pushing a message into the permanent receive fifo %p, comm %p", mbox, &(other_comm));
@@ -218,8 +218,8 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr
   /* 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 = 1;
-    other_comm->refcount--;
+    other_comm->detached = true;
+    other_comm->ref();
     other_comm->clean_fun = clean_fun;
   } else {
     other_comm->clean_fun = NULL;
@@ -295,7 +295,7 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void
         other_comm->type = SIMIX_COMM_DONE;
         other_comm->mbox = NULL;
       }
-      other_comm->refcount--;
+      other_comm->unref();
       static_cast<simgrid::simix::Comm*>(this_synchro)->unref();
     }
   } else {
@@ -374,10 +374,8 @@ smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int
     other_synchro = _find_matching_comm(mbox->comm_queue, (e_smx_comm_type_t) smx_type, match_fun, data, this_comm,/*remove_matching*/false);
   }
 
-  if(other_synchro) {
-    simgrid::simix::Comm *other_comm = static_cast<simgrid::simix::Comm*>(other_synchro);
-    other_comm->refcount--;
-  }
+  if(other_synchro)
+    other_synchro->unref();
 
   this_comm->unref();
   return other_synchro;
@@ -551,16 +549,13 @@ static inline void SIMIX_comm_start(smx_synchro_t synchro)
 
     /* If any of the process is suspend, create the synchro but stop its execution,
        it will be restarted when the sender process resume */
-    if (SIMIX_process_is_suspended(comm->src_proc) ||
-        SIMIX_process_is_suspended(comm->dst_proc)) {
-      /* FIXME: check what should happen with the synchro state */
-
+    if (SIMIX_process_is_suspended(comm->src_proc) || SIMIX_process_is_suspended(comm->dst_proc)) {
       if (SIMIX_process_is_suspended(comm->src_proc))
-        XBT_DEBUG("The communication is suspended on startup because src (%s:%s) were suspended since it initiated the communication",
-                  sg_host_get_name(comm->src_proc->host), comm->src_proc->name);
+        XBT_DEBUG("The communication is suspended on startup because src (%s@%s) was suspended since it initiated the communication",
+            comm->src_proc->name, sg_host_get_name(comm->src_proc->host));
       else
-        XBT_DEBUG("The communication is suspended on startup because dst (%s:%s) were suspended since it initiated the communication",
-                  sg_host_get_name(comm->dst_proc->host), comm->dst_proc->name);
+        XBT_DEBUG("The communication is suspended on startup because dst (%s@%s) was suspended since it initiated the communication",
+            comm->dst_proc->name, sg_host_get_name(comm->dst_proc->host));
 
       comm->surf_comm->suspend();
     }
@@ -698,45 +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                       */
 /******************************************************************************/