From c34f4c2cb7e487010a79d0ac54a1fb30fceb6227 Mon Sep 17 00:00:00 2001 From: Tim Woodall Date: Thu, 16 Mar 2006 00:05:39 +0000 Subject: [PATCH] correct cleanup for threaded case This commit was SVN r9291. --- ompi/mca/btl/gm/btl_gm.c | 33 ++++++++++++------------------ ompi/mca/btl/gm/btl_gm.h | 1 + ompi/mca/btl/gm/btl_gm_component.c | 3 ++- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/ompi/mca/btl/gm/btl_gm.c b/ompi/mca/btl/gm/btl_gm.c index b0e02f05b4..9b2bd1e00a 100644 --- a/ompi/mca/btl/gm/btl_gm.c +++ b/ompi/mca/btl/gm/btl_gm.c @@ -951,34 +951,27 @@ int mca_btl_gm_get( * Cleanup/release module resources. */ +#if OMPI_ENABLE_PROGRESS_THREADS +static void mca_btl_gm_alarm(void* arg) {} +#endif + int mca_btl_gm_finalize(struct mca_btl_base_module_t* btl) { mca_btl_gm_module_t* gm_btl = (mca_btl_gm_module_t*) btl; - -#if 0 - if(gm_btl->gm_frag_eager.fl_num_allocated != - gm_btl->gm_frag_eager.super.opal_list_length){ - opal_output(0, "btl gm_frag_eager: %d allocated %d returned \n", - gm_btl->gm_frag_eager.fl_num_allocated, - gm_btl->gm_frag_eager.super.opal_list_length); - } - if(gm_btl->gm_frag_max.fl_num_allocated != - gm_btl->gm_frag_max.super.opal_list_length) { - opal_output(0, "btl gm_frag_max: %d allocated %d returned \n", - gm_btl->gm_frag_max.fl_num_allocated, - gm_btl->gm_frag_max.super.opal_list_length); - } - if(gm_btl->gm_frag_user.fl_num_allocated != - gm_btl->gm_frag_user.super.opal_list_length){ - opal_output(0, "btl gm_frag_user: %d allocated %d returned \n", - gm_btl->gm_frag_user.fl_num_allocated, - gm_btl->gm_frag_user.super.opal_list_length); - } +#if OMPI_ENABLE_PROGRESS_THREADS + gm_alarm_t alarm; + OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock); + gm_btl->gm_progress = false; + gm_initialize_alarm(&alarm); + gm_set_alarm(gm_btl->port, &alarm, 10, mca_btl_gm_alarm, NULL); + OPAL_THREAD_UNLOCK(&mca_btl_gm_component.gm_lock); + opal_thread_join(&gm_btl->gm_thread, NULL); #endif OBJ_DESTRUCT(&gm_btl->gm_frag_eager); OBJ_DESTRUCT(&gm_btl->gm_frag_max); OBJ_DESTRUCT(&gm_btl->gm_frag_user); + gm_close(gm_btl->port); free(gm_btl); return OMPI_SUCCESS; } diff --git a/ompi/mca/btl/gm/btl_gm.h b/ompi/mca/btl/gm/btl_gm.h index 8af68676ab..186ea0877d 100644 --- a/ompi/mca/btl/gm/btl_gm.h +++ b/ompi/mca/btl/gm/btl_gm.h @@ -110,6 +110,7 @@ struct mca_btl_gm_module_t { #if OMPI_ENABLE_PROGRESS_THREADS opal_thread_t gm_thread; + bool gm_progress; #endif }; typedef struct mca_btl_gm_module_t mca_btl_gm_module_t; diff --git a/ompi/mca/btl/gm/btl_gm_component.c b/ompi/mca/btl/gm/btl_gm_component.c index 83e1e51151..4628036c26 100644 --- a/ompi/mca/btl/gm/btl_gm_component.c +++ b/ompi/mca/btl/gm/btl_gm_component.c @@ -316,6 +316,7 @@ mca_btl_gm_module_init (mca_btl_gm_module_t * btl) #if OMPI_ENABLE_PROGRESS_THREADS /* start progress thread */ + btl->gm_progress = true; btl->gm_thread.t_run = mca_btl_gm_progress_thread; btl->gm_thread.t_arg = btl; if(OPAL_SUCCESS != (rc = opal_thread_start(&btl->gm_thread))) { @@ -613,7 +614,7 @@ static void* mca_btl_gm_progress_thread( opal_object_t* arg ) pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS, NULL ); OPAL_THREAD_LOCK(&mca_btl_gm_component.gm_lock); - while(1) { + while(btl->gm_progress) { gm_recv_event_t* event; /* dont process events while the app is in the library */