X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/917c2ef999f2b31df7221183ca8caea0aef85b57..62dd6184baa87113d6bd7f536ac31196ad162945:/src/simix/smx_network.c diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index fa62223c6e..c5a62db9b3 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -119,32 +119,36 @@ static XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_action_t comm) } /** - * \brief Checks if there is a communication request queued in a rendez-vous matching our needs + * \brief Checks if there is a communication action queued in a rendez-vous matching our needs * \param type The type of communication we are looking for (comm_send, comm_recv) - * \return The communication request if found, NULL otherwise + * \return The communication action if found, NULL otherwise */ smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type, - int (*match_fun)(void *, void *), void *data) + int (*match_fun)(void *, void *), void *data) { - smx_action_t req; + smx_action_t action; xbt_fifo_item_t item; void* req_data = NULL; - xbt_fifo_foreach(rdv->comm_fifo, item, req, smx_action_t){ - if(req->comm.type == SIMIX_COMM_SEND) { - req_data = req->comm.src_data; - } else if(req->comm.type == SIMIX_COMM_RECEIVE) { - req_data = req->comm.dst_data; + xbt_fifo_foreach(rdv->comm_fifo, item, action, smx_action_t){ + if (action->comm.type == SIMIX_COMM_SEND) { + req_data = action->comm.src_data; + } else if (action->comm.type == SIMIX_COMM_RECEIVE) { + req_data = action->comm.dst_data; } - if (req->comm.type == type && (!match_fun || match_fun(data, req_data))) { + if (action->comm.type == type && (!match_fun || match_fun(data, req_data))) { + DEBUG1("Found a matching communication action %p", action); xbt_fifo_remove_item(rdv->comm_fifo, item); xbt_fifo_free_item(item); - req->comm.refcount++; - req->comm.rdv = NULL; - return req; + action->comm.refcount++; + action->comm.rdv = NULL; + return action; } + DEBUG3("Sorry, communication action %p does not match our needs:" + " its type is %d but we are looking for a comm of type %d", + action, action->comm.type, type); } - DEBUG0("Communication request not found"); + DEBUG0("No matching communication action found"); return NULL; } @@ -526,6 +530,17 @@ void SIMIX_comm_finish(smx_action_t action) default: THROW_IMPOSSIBLE; } + + /* 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); }