Skip to content

Commit 1bc3dab

Browse files
committed
Add comments about order of close ops
Per suggestion of @awlauria, added some comments about the need to free ep before resources it points to. Signed-off-by: Harumi Kuno <[email protected]>
1 parent 3095fab commit 1bc3dab

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

opal/mca/btl/ofi/btl_ofi_component.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
581581
fail:
582582
/* clean up */
583583

584+
/* close basic ep before closing av */
584585
if (NULL != ep && !module->is_scalable_ep) {
585586
fi_close(&ep->fid);
586587
}
@@ -592,10 +593,12 @@ static int mca_btl_ofi_init_device(struct fi_info *info)
592593
}
593594
free(module->contexts);
594595

596+
/* check for NULL ep to avoid double-close */
595597
if (NULL != ep) {
596598
fi_close(&ep->fid);
597599
}
598600

601+
/* close av after closing basic ep */
599602
if (NULL != av) {
600603
fi_close(&av->fid);
601604
}

opal/mca/btl/ofi/btl_ofi_module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ int mca_btl_ofi_finalize (mca_btl_base_module_t* btl)
283283
ofi_btl->rcache = NULL;
284284
}
285285

286-
/* For a standard ep, we need to close the ep first. */
286+
/* Close basic ep before closing its attached resources. */
287287
if (NULL != ofi_btl->ofi_endpoint && !ofi_btl->is_scalable_ep) {
288288
fi_close(&ofi_btl->ofi_endpoint->fid);
289289
ofi_btl->ofi_endpoint = NULL;
@@ -299,6 +299,7 @@ int mca_btl_ofi_finalize (mca_btl_base_module_t* btl)
299299
fi_close(&ofi_btl->ofi_endpoint->fid);
300300
}
301301

302+
/* close ep before closing av */
302303
if (NULL != ofi_btl->av) {
303304
fi_close(&ofi_btl->av->fid);
304305
}

0 commit comments

Comments
 (0)