Skip to content

Commit 4d4f721

Browse files
authored
Merge pull request #13003 from rhc54/topic/sing
Singletons need to create their own session directory tree
2 parents 709c74c + 9b8a417 commit 4d4f721

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

ompi/runtime/ompi_rte.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* and Technology (RIST). All rights reserved.
1515
* Copyright (c) 2020 Amazon.com, Inc. or its affiliates. All Rights
1616
* reserved.
17-
* Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
17+
* Copyright (c) 2021-2025 Nanook Consulting All rights reserved.
1818
* Copyright (c) 2021-2022 IBM Corporation. All rights reserved.
1919
* $COPYRIGHT$
2020
*/
@@ -69,6 +69,7 @@ opal_process_name_t pmix_name_invalid = {UINT32_MAX, UINT32_MAX};
6969
* session directory structure, then we shall cleanup after ourselves.
7070
*/
7171
static bool destroy_job_session_dir = false;
72+
static bool destroy_proc_session_dir = false;
7273

7374
static int _setup_top_session_dir(char **sdir);
7475
static int _setup_job_session_dir(char **sdir);
@@ -995,9 +996,12 @@ int ompi_rte_finalize(void)
995996
opal_process_info.top_session_dir = NULL;
996997
}
997998

998-
if (NULL != opal_process_info.proc_session_dir) {
999+
if (NULL != opal_process_info.proc_session_dir && destroy_proc_session_dir) {
1000+
opal_os_dirpath_destroy(opal_process_info.proc_session_dir,
1001+
false, check_file);
9991002
free(opal_process_info.proc_session_dir);
10001003
opal_process_info.proc_session_dir = NULL;
1004+
destroy_proc_session_dir = false;
10011005
}
10021006

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

11751179
static int _setup_job_session_dir(char **sdir)
11761180
{
1181+
int rc;
11771182
/* get the effective uid */
11781183
uid_t uid = geteuid();
11791184

@@ -1185,18 +1190,34 @@ static int _setup_job_session_dir(char **sdir)
11851190
opal_process_info.job_session_dir = NULL;
11861191
return OPAL_ERR_OUT_OF_RESOURCE;
11871192
}
1193+
rc = opal_os_dirpath_create(opal_process_info.job_session_dir, 0755);
1194+
if (OPAL_SUCCESS != rc) {
1195+
// could not create session dir
1196+
free(opal_process_info.job_session_dir);
1197+
opal_process_info.job_session_dir = NULL;
1198+
return rc;
1199+
}
11881200
destroy_job_session_dir = true;
11891201
return OPAL_SUCCESS;
11901202
}
11911203

11921204
static int _setup_proc_session_dir(char **sdir)
11931205
{
1206+
int rc;
1207+
11941208
if (0 > opal_asprintf(sdir, "%s/%d",
11951209
opal_process_info.job_session_dir,
11961210
opal_process_info.my_name.vpid)) {
11971211
opal_process_info.proc_session_dir = NULL;
11981212
return OPAL_ERR_OUT_OF_RESOURCE;
11991213
}
1200-
1214+
rc = opal_os_dirpath_create(opal_process_info.proc_session_dir, 0755);
1215+
if (OPAL_SUCCESS != rc) {
1216+
// could not create session dir
1217+
free(opal_process_info.proc_session_dir);
1218+
opal_process_info.proc_session_dir = NULL;
1219+
return rc;
1220+
}
1221+
destroy_proc_session_dir = true;
12011222
return OPAL_SUCCESS;
12021223
}

0 commit comments

Comments
 (0)