- SIMIX_comm_destroy(synchro);
-}
-
-/**
- * \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)
-{
- /* Update synchro state */
- if (synchro->comm.src_timeout &&
- surf_action_get_state(synchro->comm.src_timeout) == SURF_ACTION_DONE)
- synchro->state = SIMIX_SRC_TIMEOUT;
- else if (synchro->comm.dst_timeout &&
- surf_action_get_state(synchro->comm.dst_timeout) == SURF_ACTION_DONE)
- synchro->state = SIMIX_DST_TIMEOUT;
- else if (synchro->comm.src_timeout &&
- surf_action_get_state(synchro->comm.src_timeout) == SURF_ACTION_FAILED)
- synchro->state = SIMIX_SRC_HOST_FAILURE;
- else if (synchro->comm.dst_timeout &&
- surf_action_get_state(synchro->comm.dst_timeout) == SURF_ACTION_FAILED)
- synchro->state = SIMIX_DST_HOST_FAILURE;
- else if (synchro->comm.surf_comm &&
- surf_action_get_state(synchro->comm.surf_comm) == SURF_ACTION_FAILED) {
- XBT_DEBUG("Puta madre. Surf says that the link broke");
- 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",
- synchro, (int)synchro->state, synchro->comm.src_proc, synchro->comm.dst_proc, synchro->comm.detached);
-
- /* destroy the surf actions associated with the Simix communication */
- SIMIX_comm_destroy_internal_actions(synchro);
-
- /* if there are simcalls associated with the synchro, then answer them */
- if (xbt_fifo_size(synchro->simcalls)) {
- SIMIX_comm_finish(synchro);
- }
-}
-
-void SIMIX_comm_cancel(smx_synchro_t synchro)
-{
- /* if the synchro is a waiting state means that it is still in a rdv */
- /* so remove from it and delete it */
- if (synchro->state == SIMIX_WAITING) {
- SIMIX_rdv_remove(synchro->comm.rdv, synchro);
- synchro->state = SIMIX_CANCELED;
- }
- else if (!MC_is_active() /* when running the MC there are no surf actions */
- && !MC_record_replay_is_active()
- && (synchro->state == SIMIX_READY || synchro->state == SIMIX_RUNNING)) {
-
- surf_action_cancel(synchro->comm.surf_comm);
- }
-}
-
-void SIMIX_comm_suspend(smx_synchro_t synchro)
-{
- /*FIXME: shall we suspend also the timeout synchro? */
- if (synchro->comm.surf_comm)
- surf_action_suspend(synchro->comm.surf_comm);
- /* in the other case, the action will be suspended on creation, in SIMIX_comm_start() */
-}
-
-void SIMIX_comm_resume(smx_synchro_t synchro)
-{
- /*FIXME: check what happen with the timeouts */
- if (synchro->comm.surf_comm)
- surf_action_resume(synchro->comm.surf_comm);
- /* in the other case, the synchro were not really suspended yet, see SIMIX_comm_suspend() and SIMIX_comm_start() */
-}
-
-
-/************* synchro Getters **************/
-
-/**
- * \brief get the amount remaining from the communication
- * \param synchro The communication
- */
-double SIMIX_comm_get_remains(smx_synchro_t synchro)
-{
- double remains;
-
- if(!synchro){
- return 0;
- }
-
- switch (synchro->state) {
-
- case SIMIX_RUNNING:
- remains = surf_action_get_remains(synchro->comm.surf_comm);
- break;
-
- case SIMIX_WAITING:
- case SIMIX_READY:
- remains = 0; /*FIXME: check what should be returned */
- break;
-
- default:
- remains = 0; /*FIXME: is this correct? */
- break;
- }
- return remains;