+ /* if there is an exception during a waitany or a testany, indicate the position of the failed communication */
+ if (req->issuer->doexception) {
+ if (req->call == REQ_COMM_WAITANY) {
+ req->issuer->running_ctx->exception.value = xbt_dynar_search(req->comm_waitany.comms, &action);
+ }
+ else if (req->call == REQ_COMM_TESTANY) {
+ req->issuer->running_ctx->exception.value = xbt_dynar_search(req->comm_testany.comms, &action);
+ }
+ }
+
+ req->issuer->waiting_action = NULL;
+ SIMIX_request_answer(req);
+ destroy_count++;
+ }
+
+ while (destroy_count-- > 0)
+ SIMIX_comm_destroy(action);
+}
+
+void SIMIX_post_comm(smx_action_t action)
+{
+ /* Update action state */
+ if (action->comm.src_timeout &&
+ surf_workstation_model->action_state_get(action->comm.src_timeout) == SURF_ACTION_DONE)
+ action->state = SIMIX_SRC_TIMEOUT;
+ else if (action->comm.dst_timeout &&
+ surf_workstation_model->action_state_get(action->comm.dst_timeout) == SURF_ACTION_DONE)
+ action->state = SIMIX_DST_TIMEOUT;
+ else if (action->comm.src_timeout &&
+ surf_workstation_model->action_state_get(action->comm.src_timeout) == SURF_ACTION_FAILED)
+ action->state = SIMIX_SRC_HOST_FAILURE;
+ else if (action->comm.dst_timeout &&
+ surf_workstation_model->action_state_get(action->comm.dst_timeout) == SURF_ACTION_FAILED)
+ action->state = SIMIX_DST_HOST_FAILURE;
+ else if (action->comm.surf_comm &&
+ surf_workstation_model->action_state_get(action->comm.surf_comm) == SURF_ACTION_FAILED)
+ action->state = SIMIX_LINK_FAILURE;
+ else
+ action->state = SIMIX_DONE;
+
+ XBT_DEBUG("SIMIX_post_comm: comm %p, state %d, src_proc %p, dst_proc %p, detached: %d",
+ action, action->state, action->comm.src_proc, action->comm.dst_proc, action->comm.detached);
+
+ /* remove the action from pending communications of both processes (if they still exist) */
+ if (action->comm.src_proc) {
+ xbt_fifo_remove(action->comm.src_proc->comms, action);
+ }
+ if (action->comm.dst_proc) {
+ xbt_fifo_remove(action->comm.dst_proc->comms, action);
+ }
+
+ /* destroy the surf actions associated with the Simix communication */
+ SIMIX_comm_destroy_internal_actions(action);
+
+ /* if there are requests associated with the action, then answer them */
+ if (xbt_fifo_size(action->request_list))
+ SIMIX_comm_finish(action);
+}
+
+void SIMIX_comm_cancel(smx_action_t action)
+{
+ /* If the action is a waiting state means that it is still in a rdv */
+ /* so remove from it and delete it */
+ if (action->state == SIMIX_WAITING) {
+ SIMIX_rdv_remove(action->comm.rdv, action);
+ action->state = SIMIX_FAILED;
+ } else {
+ /* When running the MC there are no surf actions */
+ if(!MC_IS_ENABLED)
+ surf_workstation_model->action_cancel(action->comm.surf_comm);
+ }