diff --git a/src/mpid/ch4/include/mpidch4.h b/src/mpid/ch4/include/mpidch4.h index 3dd3528efbc..a2cfa177829 100644 --- a/src/mpid/ch4/include/mpidch4.h +++ b/src/mpid/ch4/include/mpidch4.h @@ -474,6 +474,6 @@ extern MPL_dbg_class MPIDI_CH4_DBG_MEMORY; /* routines only used during init */ int MPIDI_create_init_comm(MPIR_Comm ** comm_ptr); -void MPIDI_destroy_init_comm(MPIR_Comm ** comm_ptr); +int MPIDI_destroy_init_comm(MPIR_Comm ** comm_ptr); #endif /* MPIDCH4_H_INCLUDED */ diff --git a/src/mpid/ch4/netmod/ofi/init_addrxchg.c b/src/mpid/ch4/netmod/ofi/init_addrxchg.c index 7a1766df84e..21ea813517e 100644 --- a/src/mpid/ch4/netmod/ofi/init_addrxchg.c +++ b/src/mpid/ch4/netmod/ofi/init_addrxchg.c @@ -180,7 +180,7 @@ int MPIDI_OFI_addr_exchange_root_ctx(void) fn_exit: if (init_comm && !mpi_errno) { - MPIDI_destroy_init_comm(&init_comm); + mpi_errno = MPIDI_destroy_init_comm(&init_comm); } return mpi_errno; fn_fail: diff --git a/src/mpid/ch4/netmod/ucx/ucx_init.c b/src/mpid/ch4/netmod/ucx/ucx_init.c index fd7698bbebf..7c4786af293 100644 --- a/src/mpid/ch4/netmod/ucx/ucx_init.c +++ b/src/mpid/ch4/netmod/ucx/ucx_init.c @@ -140,7 +140,7 @@ static int initial_address_exchange(void) fn_exit: if (init_comm && !mpi_errno) { - MPIDI_destroy_init_comm(&init_comm); + mpi_errno = MPIDI_destroy_init_comm(&init_comm); } return mpi_errno; fn_fail: diff --git a/src/mpid/ch4/src/init_comm.c b/src/mpid/ch4/src/init_comm.c index e546337bd6f..0fbc4999460 100644 --- a/src/mpid/ch4/src/init_comm.c +++ b/src/mpid/ch4/src/init_comm.c @@ -60,18 +60,24 @@ int MPIDI_create_init_comm(MPIR_Comm ** comm) goto fn_exit; } -void MPIDI_destroy_init_comm(MPIR_Comm ** comm_ptr) +int MPIDI_destroy_init_comm(MPIR_Comm ** comm_ptr) { + int mpi_errno = MPI_SUCCESS; int in_use; MPIR_Comm *comm = NULL; if (*comm_ptr != NULL) { comm = *comm_ptr; MPIDIU_release_lut(MPIDI_COMM(comm, map).irreg.lut.t); MPIDIG_destroy_comm(comm); + /* wait for any outstanding requests to complete */ + MPIDIU_PROGRESS_WHILE(MPIR_Object_get_ref(comm) > 1, 0); MPIR_Object_release_ref(comm, &in_use); MPIR_Assertp(in_use == 0); MPII_COMML_FORGET(comm); MPIR_Handle_obj_free(&MPIR_Comm_mem, comm); *comm_ptr = NULL; } + + fn_fail: + return mpi_errno; }