Skip to content

Commit

Permalink
Merge pull request #13003 from rhc54/topic/sing
Browse files Browse the repository at this point in the history
Singletons need to create their own session directory tree
  • Loading branch information
jsquyres authored Jan 13, 2025
2 parents 709c74c + 9b8a417 commit 4d4f721
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions ompi/runtime/ompi_rte.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* and Technology (RIST). All rights reserved.
* Copyright (c) 2020 Amazon.com, Inc. or its affiliates. All Rights
* reserved.
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
* Copyright (c) 2021-2025 Nanook Consulting All rights reserved.
* Copyright (c) 2021-2022 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*/
Expand Down Expand Up @@ -69,6 +69,7 @@ opal_process_name_t pmix_name_invalid = {UINT32_MAX, UINT32_MAX};
* session directory structure, then we shall cleanup after ourselves.
*/
static bool destroy_job_session_dir = false;
static bool destroy_proc_session_dir = false;

static int _setup_top_session_dir(char **sdir);
static int _setup_job_session_dir(char **sdir);
Expand Down Expand Up @@ -995,9 +996,12 @@ int ompi_rte_finalize(void)
opal_process_info.top_session_dir = NULL;
}

if (NULL != opal_process_info.proc_session_dir) {
if (NULL != opal_process_info.proc_session_dir && destroy_proc_session_dir) {
opal_os_dirpath_destroy(opal_process_info.proc_session_dir,
false, check_file);
free(opal_process_info.proc_session_dir);
opal_process_info.proc_session_dir = NULL;
destroy_proc_session_dir = false;
}

if (NULL != opal_process_info.app_sizes) {
Expand Down Expand Up @@ -1174,6 +1178,7 @@ static int _setup_top_session_dir(char **sdir)

static int _setup_job_session_dir(char **sdir)
{
int rc;
/* get the effective uid */
uid_t uid = geteuid();

Expand All @@ -1185,18 +1190,34 @@ static int _setup_job_session_dir(char **sdir)
opal_process_info.job_session_dir = NULL;
return OPAL_ERR_OUT_OF_RESOURCE;
}
rc = opal_os_dirpath_create(opal_process_info.job_session_dir, 0755);
if (OPAL_SUCCESS != rc) {
// could not create session dir
free(opal_process_info.job_session_dir);
opal_process_info.job_session_dir = NULL;
return rc;
}
destroy_job_session_dir = true;
return OPAL_SUCCESS;
}

static int _setup_proc_session_dir(char **sdir)
{
int rc;

if (0 > opal_asprintf(sdir, "%s/%d",
opal_process_info.job_session_dir,
opal_process_info.my_name.vpid)) {
opal_process_info.proc_session_dir = NULL;
return OPAL_ERR_OUT_OF_RESOURCE;
}

rc = opal_os_dirpath_create(opal_process_info.proc_session_dir, 0755);
if (OPAL_SUCCESS != rc) {
// could not create session dir
free(opal_process_info.proc_session_dir);
opal_process_info.proc_session_dir = NULL;
return rc;
}
destroy_proc_session_dir = true;
return OPAL_SUCCESS;
}

0 comments on commit 4d4f721

Please sign in to comment.