From: degomme Date: Thu, 12 May 2016 12:56:38 +0000 (+0200) Subject: Try to avoid leaking detached comms. X-Git-Tag: v3_14~1239^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/57e802c93f2b396e42e8a02e03b92c36aca2e8cf?ds=sidebyside Try to avoid leaking detached comms. --- diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 51a5ab74aa..3db60d6ac4 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -215,11 +215,9 @@ smx_synchro_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_process_t sr } xbt_fifo_push(src_proc->comms, other_synchro); - /* if the communication synchro is detached then decrease the refcount - * by one, so it will be eliminated by the receiver's destroy call */ + if (detached) { other_comm->detached = true; - other_comm->ref(); other_comm->clean_fun = clean_fun; } else { other_comm->clean_fun = NULL; @@ -683,6 +681,8 @@ void SIMIX_comm_finish(smx_synchro_t synchro) if(simcall->issuer == comm->dst_proc){ if(comm->src_proc) xbt_fifo_remove(comm->src_proc->comms, synchro); + //in case of a detached comm we have an extra ref to remove, as the sender won't do it + destroy_count++; } } SIMIX_simcall_answer(simcall); diff --git a/src/simix/smx_process.cpp b/src/simix/smx_process.cpp index ef55883fa2..32b5c8cd60 100644 --- a/src/simix/smx_process.cpp +++ b/src/simix/smx_process.cpp @@ -91,10 +91,11 @@ void SIMIX_process_cleanup(smx_process_t process) comm, (int)comm->state, comm->src_proc, comm->dst_proc); comm->dst_proc = NULL; - if (comm->detached && /* FIXME: This code should be moved within comm->unref() anyway. comm->refcount == 1 &&*/ comm->src_proc != NULL) { + if (comm->detached && comm->src_proc != NULL) { /* the comm will be freed right now, remove it from the sender */ xbt_fifo_remove(comm->src_proc->comms, comm); } + comm->unref(); } else { xbt_die("Communication synchro %p is in my list but I'm not the sender nor the receiver", synchro);