Skip to content

Commit 4f71d98

Browse files
committed
added proper cleanup code for pending probe operation
1 parent 01ab0fd commit 4f71d98

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/mona.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,18 @@ mona_instance_t mona_init_na_pool(na_class_t* na_class,
210210

211211
na_return_t mona_finalize(mona_instance_t mona)
212212
{
213+
if(mona->unexpected.prob_active) {
214+
na_return_t na_ret = NA_Cancel(
215+
mona->na_class, mona->na_context, mona->unexpected.prob_id->op_id);
216+
if(na_ret != NA_SUCCESS) {
217+
fprintf(stderr, "WARNING: MoNA could not cancel probe operation\n");
218+
} else {
219+
mona_wait(mona->unexpected.prob_req);
220+
return_op_id_to_cache(mona, mona->unexpected.prob_id);
221+
return_msg_to_cache(mona, mona->unexpected.prob_msg, false);
222+
}
223+
}
224+
213225
mona->finalize_flag = true;
214226
ABT_thread_join(mona->progress_thread);
215227

tests/test-usend-urecv.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,26 @@ static MunitResult test_usend_urecv_probe(const MunitParameter params[], void* d
170170
return MUNIT_OK;
171171
}
172172

173+
static MunitResult test_only_probe(const MunitParameter params[], void* data)
174+
{
175+
(void)params;
176+
test_context* context = (test_context*)data;
177+
na_return_t ret;
178+
mona_instance_t mona = context->mona;
179+
180+
int flag = 0;
181+
ret = mona_uiprobe(mona, MONA_ANY_ADDR, MONA_ANY_TAG, &flag,
182+
NULL, NULL, NULL);
183+
munit_assert_int(ret, ==, NA_SUCCESS);
184+
munit_assert_int(flag, ==, 0);
185+
186+
return MUNIT_OK;
187+
}
188+
173189
static MunitTest test_suite_tests[] = {
174190
{ (char*) "/hl", test_usend_urecv, test_context_setup, test_context_tear_down, MUNIT_TEST_OPTION_NONE, NULL },
175-
{ (char*) "/probe", test_usend_urecv_probe, test_context_setup, test_context_tear_down, MUNIT_TEST_OPTION_NONE, NULL },
191+
{ (char*) "/send_recv_probe", test_usend_urecv_probe, test_context_setup, test_context_tear_down, MUNIT_TEST_OPTION_NONE, NULL },
192+
{ (char*) "/only_probe", test_only_probe, test_context_setup, test_context_tear_down, MUNIT_TEST_OPTION_NONE, NULL },
176193
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
177194
};
178195

0 commit comments

Comments
 (0)