From 9c2cd19692ab0840b821f57e9269fbf601ccfc06 Mon Sep 17 00:00:00 2001 From: Matthieu Dorier Date: Tue, 27 Aug 2024 18:23:59 +0100 Subject: [PATCH] changed where finalization callbacks are called --- src/margo-core.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/margo-core.c b/src/margo-core.c index 2e58be7..fa25b68 100644 --- a/src/margo-core.c +++ b/src/margo-core.c @@ -114,18 +114,8 @@ margo_instance_id margo_init_pool(ABT_pool progress_pool, } // LCOV_EXCL_END -static void margo_cleanup(margo_instance_id mid) +static void margo_call_finalization_callbacks(margo_instance_id mid) { - MARGO_TRACE(mid, "Entering margo_cleanup"); - struct margo_registered_rpc* next_rpc; - - /* monitoring */ - struct margo_monitor_finalize_args monitoring_args = {0}; - __MARGO_MONITOR(mid, FN_START, finalize, monitoring_args); - - margo_deregister(mid, mid->shutdown_rpc_id); - margo_deregister(mid, mid->identity_rpc_id); - /* call finalize callbacks */ MARGO_TRACE(mid, "Calling finalize callbacks"); struct margo_finalize_cb* fcb = mid->finalize_cb; @@ -136,6 +126,19 @@ static void margo_cleanup(margo_instance_id mid) fcb = mid->finalize_cb; free(tmp); } +} + +static void margo_cleanup(margo_instance_id mid) +{ + MARGO_TRACE(mid, "Entering margo_cleanup"); + struct margo_registered_rpc* next_rpc; + + /* monitoring */ + struct margo_monitor_finalize_args monitoring_args = {0}; + __MARGO_MONITOR(mid, FN_START, finalize, monitoring_args); + + margo_deregister(mid, mid->shutdown_rpc_id); + margo_deregister(mid, mid->identity_rpc_id); /* Start with the handle cache, to clean up any Mercury-related * data */ @@ -270,7 +273,8 @@ void margo_finalize(margo_instance_id mid) ABT_mutex_lock(mid->finalize_mutex); mid->finalize_flag = true; - do_cleanup = mid->finalize_refcount == 0 && mid->refcount == 0; + margo_call_finalization_callbacks(mid); + do_cleanup = mid->finalize_refcount == 0 && mid->refcount == 0; ABT_mutex_unlock(mid->finalize_mutex); ABT_cond_broadcast(mid->finalize_cond);