X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fe3f93cc16d6505056d5d5dc8fb63dbea26b9ef2..8a70fd6e0cc77910dda2e50a7f8bbb864f26c0b9:/src/simix/smx_network.c diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index aa46dc3450..7732d2a5f5 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -19,12 +19,10 @@ static void SIMIX_comm_finish(smx_action_t action); static void SIMIX_waitany_req_remove_from_actions(smx_req_t req); static void SIMIX_comm_copy_data(smx_action_t comm); static smx_action_t SIMIX_comm_new(e_smx_comm_type_t type); -static XBT_INLINE void SIMIX_comm_wait_for_completion(smx_action_t comm, - double timeout); static XBT_INLINE void SIMIX_rdv_push(smx_rdv_t rdv, smx_action_t comm); static XBT_INLINE void SIMIX_rdv_remove(smx_rdv_t rdv, smx_action_t comm); static smx_action_t SIMIX_rdv_get_request(smx_rdv_t rdv, e_smx_comm_type_t type, - int (*match_fun)(void *, void *), void *); + int (*match_fun)(void *, void *), void *); static void SIMIX_rdv_free(void *data); void SIMIX_network_init(void) @@ -221,6 +219,12 @@ void SIMIX_comm_destroy(smx_action_t action) SIMIX_comm_destroy_internal_actions(action); + if (action->comm.detached && action->state != SIMIX_DONE) { + /* the communication has failed and was detached: + * we have to free the buffer */ + ((void_f_pvoid_t) action->comm.src_data)(action->comm.src_buff); + } + xbt_free(action); } @@ -248,7 +252,8 @@ void SIMIX_comm_destroy_internal_actions(smx_action_t action) smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv, double task_size, double rate, void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *), void *data) + int (*match_fun)(void *, void *), void *data, + int detached) { smx_action_t action; @@ -264,6 +269,13 @@ smx_action_t SIMIX_comm_isend(smx_process_t src_proc, smx_rdv_t rdv, action->comm.type = SIMIX_COMM_READY; } + /* If the communication action is detached then decrease the refcount + * by one, so it will be eliminated by the receivers destroy call */ + if (detached) { + action->comm.detached = 1; + action->comm.refcount--; + } + /* Setup the communication request */ action->comm.src_proc = src_proc; action->comm.task_size = task_size; @@ -496,6 +508,7 @@ static XBT_INLINE void SIMIX_comm_start(smx_action_t action) void SIMIX_comm_finish(smx_action_t action) { + unsigned int destroy_count = 0; smx_req_t req; while ((req = xbt_fifo_shift(action->request_list))) { @@ -594,7 +607,11 @@ void SIMIX_comm_finish(smx_action_t 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)