- DEBUG1("Communication %p complete! Let's check for errors", comm);
-
- /* Make sure that everyone sleeping on that semaphore is awake, and that nobody will ever block on it */
- SIMIX_sem_release_forever(comm->sem);
-
- /* Check for errors other than timeouts (they are catched above) */
- if(!SIMIX_host_get_state(SIMIX_host_self())){
- if(comm->rdv)
- SIMIX_rdv_remove(comm->rdv, comm);
- SIMIX_communication_destroy(comm);
- THROW0(host_error, 0, "Host failed");
- } else if (SIMIX_action_get_state(comm->act) == SURF_ACTION_FAILED){
- SIMIX_communication_destroy(comm);
- THROW0(network_error, 0, "Link failure");
+ /* If the action is still in a rendez-vous point then remove from it */
+ if (action->comm.rdv)
+ SIMIX_rdv_remove(action->comm.rdv, action);
+
+ DEBUG1("SIMIX_comm_finish: action state = %d", action->state);
+
+ /* Check out for errors */
+ switch (action->state) {
+
+ case SIMIX_DONE:
+ DEBUG1("Communication %p complete!", action);
+ SIMIX_comm_copy_data(action);
+ break;
+
+ case SIMIX_SRC_TIMEOUT:
+ TRY {
+ THROW0(timeout_error, 0, "Communication timeouted because of sender");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_DST_TIMEOUT:
+ TRY {
+ THROW0(timeout_error, 0, "Communication timeouted because of receiver");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_SRC_HOST_FAILURE:
+ TRY {
+ if (req->issuer == action->comm.src_proc)
+ THROW0(host_error, 0, "Host failed");
+ else
+ THROW0(network_error, 0, "Remote peer failed");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_DST_HOST_FAILURE:
+ TRY {
+ if (req->issuer == action->comm.dst_proc)
+ THROW0(host_error, 0, "Host failed");
+ else
+ THROW0(network_error, 0, "Remote peer failed");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ case SIMIX_LINK_FAILURE:
+ TRY {
+ DEBUG5("Link failure in action %p between '%s' and '%s': posting an exception to the issuer: %s (%p)",
+ action, action->comm.src_proc->smx_host->name, action->comm.dst_proc->smx_host->name,
+ req->issuer->name, req->issuer);
+ THROW0(network_error, 0, "Link failure");
+ }
+ CATCH(req->issuer->running_ctx->exception) {
+ req->issuer->doexception = 1;
+ }
+ break;
+
+ default:
+ THROW_IMPOSSIBLE;
+ }
+ req->issuer->waiting_action = NULL;
+ SIMIX_request_answer(req);