Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed where finalization callbacks are called #286

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading