Skip to content

Commit

Permalink
changed where finalization callbacks are called
Browse files Browse the repository at this point in the history
  • Loading branch information
mdorier committed Aug 27, 2024
1 parent 84245fe commit 9c2cd19
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/margo-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9c2cd19

Please sign in to comment.