Skip to content

Commit

Permalink
pmi+hydra: do not close PMI_fd on PMI_Finalize
Browse files Browse the repository at this point in the history
We may call PMI_Finalize multiple times. For example, when process goes
through multiple init, or when user uses PMI separately from MPI. Not
closing PMI_fd allows the reinit to happen. The fd will be closed upon
process exit by OS.
  • Loading branch information
hzhou committed Feb 17, 2023
1 parent ab17b26 commit 6a103ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/pm/hydra/proxy/pmip_pmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,12 @@ HYD_status fn_finalize(struct pmip_downstream *p, struct PMIU_cmd *pmi)
status = send_cmd_downstream(p->pmi_fd, &pmi_response);
HYDU_ERR_POP(status, "error sending PMI response\n");

status = HYDT_dmx_deregister_fd(p->pmi_fd);
HYDU_ERR_POP(status, "unable to deregister fd\n");
close(p->pmi_fd);
if (HYD_pmcd_pmip.user_global.auto_cleanup) {
/* deregister to prevent the cleanup kill on fd close */
status = HYDT_dmx_deregister_fd(p->pmi_fd);
HYDU_ERR_POP(status, "unable to deregister fd\n");
close(p->pmi_fd);
}

/* mark singleton's stdio sockets as closed */
if (pg->is_singleton) {
Expand Down
7 changes: 5 additions & 2 deletions src/pmi/src/pmi_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,11 @@ PMI_API_PUBLIC int PMI_Finalize(void)
pmi_errno = PMIU_cmd_get_response(PMI_fd, &pmicmd);
PMIU_ERR_POP(pmi_errno);

shutdown(PMI_fd, SHUT_RDWR);
close(PMI_fd);
if (0) {
/* closing PMI_fd prevents re-init. Disable for now. */
shutdown(PMI_fd, SHUT_RDWR);
close(PMI_fd);
}
}

fn_exit:
Expand Down

0 comments on commit 6a103ee

Please sign in to comment.