From 2fe63dd198ff331f7fe3a483bc2e2f71bdb8a045 Mon Sep 17 00:00:00 2001 From: velho Date: Thu, 18 Nov 2010 17:14:36 +0000 Subject: [PATCH] Bug fix inspired by Arnaud Guiersh's patch but that required one day of investigation to be functionnal!!! git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8585 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/msg/msg_mailbox.c | 3 +-- src/simix/smx_network.c | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/msg/msg_mailbox.c b/src/msg/msg_mailbox.c index 1f984107d9..a6f053b28c 100644 --- a/src/msg/msg_mailbox.c +++ b/src/msg/msg_mailbox.c @@ -185,7 +185,6 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task, { xbt_ex_t e; MSG_error_t ret = MSG_OK; - smx_comm_t comm; simdata_task_t t_simdata = NULL; m_process_t process = MSG_process_self(); #ifdef HAVE_TRACING @@ -219,7 +218,7 @@ MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, m_task_t task, SIMIX_network_send(mailbox->rdv, t_simdata->message_size, t_simdata->rate, timeout, task, sizeof(void *), - &comm, task); + &(t_simdata->comm), task); } CATCH(e) { diff --git a/src/simix/smx_network.c b/src/simix/smx_network.c index 15039a14c7..b84c935f77 100644 --- a/src/simix/smx_network.c +++ b/src/simix/smx_network.c @@ -156,6 +156,8 @@ smx_comm_t SIMIX_communication_new(smx_comm_type_t type) comm->type = type; comm->sem = SIMIX_sem_init(0); comm->refcount = 1; + VERB2("Create communication %p; refcount initially %d", comm, + comm->refcount); return comm; } @@ -169,6 +171,11 @@ void SIMIX_communication_destroy(smx_comm_t comm) VERB2("Destroy communication %p; refcount initially %d", comm, comm->refcount); + if(!(comm->refcount>0)) { + INFO1("There is no more reference to this comm (%p). Cannot destroy!",comm); + xbt_die("Argh.!"); + } + #ifdef HAVE_LATENCY_BOUND_TRACKING //save is latency limited flag to use afterwards if (latency_limited_dict == NULL) { @@ -224,6 +231,9 @@ void SIMIX_communication_destroy(smx_comm_t comm) static XBT_INLINE void SIMIX_communication_use(smx_comm_t comm) { comm->refcount++; + + VERB2("Use communication %p; refcount is now %d", comm, + comm->refcount); } /** @@ -557,14 +567,14 @@ XBT_INLINE void SIMIX_network_send(smx_rdv_t rdv, double task_size, smx_comm_t * comm_ref, void *data) { xbt_ex_t e; - *comm_ref = - SIMIX_network_isend(rdv, task_size, rate, src_buff, src_buff_size, - data); + smx_comm_t comm = *comm_ref = + SIMIX_network_isend(rdv, task_size, rate, src_buff, src_buff_size, + data); TRY { - SIMIX_network_wait(*comm_ref, timeout); + SIMIX_network_wait(comm, timeout); } TRY_CLEANUP { - SIMIX_communication_destroy(*comm_ref); + SIMIX_communication_destroy(comm); } CATCH(e) { RETHROW; @@ -589,13 +599,13 @@ XBT_INLINE void SIMIX_network_recv(smx_rdv_t rdv, double timeout, smx_comm_t * comm_ref) { xbt_ex_t e; - *comm_ref = + smx_comm_t comm = *comm_ref = (smx_comm_t) SIMIX_network_irecv(rdv, dst_buff, dst_buff_size); TRY { - SIMIX_network_wait(*comm_ref, timeout); + SIMIX_network_wait(comm, timeout); } TRY_CLEANUP { - SIMIX_communication_destroy(*comm_ref); + SIMIX_communication_destroy(comm); } CATCH(e) { RETHROW; -- 2.20.1