Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion orte/mca/ess/base/ess_base_std_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int orte_ess_base_app_setup(bool db_restrict_local)

if (ORTE_SUCCESS != (ret = orte_session_dir(true,
orte_process_info.tmpdir_base,
orte_process_info.nodename, NULL,
orte_process_info.nodename,
ORTE_PROC_MY_NAME))) {
ORTE_ERROR_LOG(ret);
error = "orte_session_dir";
Expand Down
4 changes: 2 additions & 2 deletions orte/mca/ess/base/ess_base_std_orted.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int orte_ess_base_orted_setup(char **hosts)
*/
if (ORTE_SUCCESS != (ret = orte_session_dir(false,
orte_process_info.tmpdir_base,
orte_process_info.nodename, NULL,
orte_process_info.nodename,
ORTE_PROC_MY_NAME))) {
ORTE_ERROR_LOG(ret);
error = "orte_session_dir define";
Expand All @@ -255,7 +255,7 @@ int orte_ess_base_orted_setup(char **hosts)
/* now actually create the directory tree */
if (ORTE_SUCCESS != (ret = orte_session_dir(true,
orte_process_info.tmpdir_base,
orte_process_info.nodename, NULL,
orte_process_info.nodename,
ORTE_PROC_MY_NAME))) {
ORTE_ERROR_LOG(ret);
error = "orte_session_dir";
Expand Down
2 changes: 1 addition & 1 deletion orte/mca/ess/base/ess_base_std_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ int orte_ess_base_tool_setup(void)
if (ORTE_SUCCESS != (ret = orte_session_dir_get_name(NULL,
&orte_process_info.tmpdir_base,
&orte_process_info.top_session_dir,
orte_process_info.nodename, NULL, NULL))) {
orte_process_info.nodename, NULL))) {
ORTE_ERROR_LOG(ret);
error = "define session dir names";
goto error;
Expand Down
4 changes: 2 additions & 2 deletions orte/mca/ess/hnp/ess_hnp_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int rte_init(void)
*/
if (ORTE_SUCCESS != (ret = orte_session_dir(false,
orte_process_info.tmpdir_base,
orte_process_info.nodename, NULL,
orte_process_info.nodename,
ORTE_PROC_MY_NAME))) {
error = "orte_session_dir define";
goto error;
Expand All @@ -305,7 +305,7 @@ static int rte_init(void)
/* now actually create the directory tree */
if (ORTE_SUCCESS != (ret = orte_session_dir(true,
orte_process_info.tmpdir_base,
orte_process_info.nodename, NULL,
orte_process_info.nodename,
ORTE_PROC_MY_NAME))) {
error = "orte_session_dir";
goto error;
Expand Down
2 changes: 1 addition & 1 deletion orte/mca/filem/raw/filem_raw_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ static int raw_link_local_files(orte_job_t *jdata,
path = NULL;
rc = orte_session_dir_get_name(&path, &prefix, NULL,
orte_process_info.nodename,
NULL, &proc->name);
&proc->name);
/* create it, if it doesn't already exist */
if (OPAL_SUCCESS != (rc = opal_os_dirpath_create(path, S_IRWXU))) {
ORTE_ERROR_LOG(rc);
Expand Down
2 changes: 1 addition & 1 deletion orte/mca/schizo/ompi/schizo_ompi.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ static int setup_child(orte_job_t *jdata,
param = NULL;
if (ORTE_SUCCESS != (rc = orte_session_dir_get_name(&param, &value, NULL,
orte_process_info.nodename,
NULL, &child->name))) {
&child->name))) {
ORTE_ERROR_LOG(rc);
if (NULL != value) {
free(value);
Expand Down
132 changes: 60 additions & 72 deletions orte/util/session_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,17 @@ static int orte_create_dir(char *directory)
}

/*
* Construct the fullpath to the session directory
* Construct the fullpath to the session directory - it
* will consist of "ompi.<hostname>.<pid>"
*/
int
orte_session_dir_get_name(char **fulldirpath,
char **return_prefix, /* This will come back as the valid tmp dir */
char **return_frontend,
char *hostid,
char *batchid,
orte_process_name_t *proc) {
char *hostname = NULL,
*batchname = NULL,
*sessions = NULL,
*user = NULL,
*prefix = NULL,
*frontend = NULL,
*jobfam = NULL,
Expand All @@ -134,15 +132,10 @@ orte_session_dir_get_name(char **fulldirpath,
bool prefix_provided = false;
int exit_status = ORTE_SUCCESS;
size_t len;
int uid;

/* Ensure that system info is set */
orte_proc_info();

/* get the name of the user */
uid = getuid();
asprintf(&user, "%d", uid);

/*
* set the 'hostname'
*/
Expand All @@ -160,24 +153,12 @@ orte_session_dir_get_name(char **fulldirpath,
}
}

/*
* set the 'batchid'
*/
if (NULL != batchid)
batchname = strdup(batchid);
else
batchname = strdup("0");

/*
* get the front part of the session directory
* Will look something like:
* openmpi-sessions-USERNAME@HOSTNAME_BATCHID
*/
/* construct the frontend of the session directory*/
if (NULL != orte_process_info.top_session_dir) {
frontend = strdup(orte_process_info.top_session_dir);
}
else { /* If not set then construct it */
if (0 > asprintf(&frontend, "openmpi-sessions-%s@%s_%s", user, hostname, batchname)) {
if (0 > asprintf(&frontend, "ompi.%s.%lu", hostname, (unsigned long)orte_process_info.pid)) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
exit_status = ORTE_ERR_OUT_OF_RESOURCE;
goto cleanup;
Expand Down Expand Up @@ -300,7 +281,6 @@ orte_session_dir_get_name(char **fulldirpath,
free(prefix);
free(sessions);
free(hostname);
free(batchname);
free(frontend);
return ORTE_ERR_FATAL;
}
Expand All @@ -325,19 +305,27 @@ orte_session_dir_get_name(char **fulldirpath,
}

cleanup:
if(NULL != hostname)
if(NULL != hostname) {
free(hostname);
if(NULL != batchname)
free(batchname);
if(NULL != sessions)
}
if(NULL != sessions) {
free(sessions);
if(NULL != user)
free(user);
if (NULL != prefix) free(prefix);
if (NULL != frontend) free(frontend);
if (NULL != jobfam) free(jobfam);
if (NULL != job) free(job);
if (NULL != vpidstr) free(vpidstr);
}
if (NULL != prefix) {
free(prefix);
}
if (NULL != frontend) {
free(frontend);
}
if (NULL != jobfam) {
free(jobfam);
}
if (NULL != job) {
free(job);
}
if (NULL != vpidstr) {
free(vpidstr);
}

return exit_status;
}
Expand All @@ -347,7 +335,7 @@ orte_session_dir_get_name(char **fulldirpath,
*/
int orte_session_dir(bool create,
char *prefix, char *hostid,
char *batchid, orte_process_name_t *proc)
orte_process_name_t *proc)
{
char *fulldirpath = NULL,
*frontend = NULL,
Expand All @@ -367,7 +355,7 @@ int orte_session_dir(bool create,
&local_prefix,
&frontend,
hostid,
batchid, proc))) {
proc))) {
if (ORTE_ERR_FATAL == rc) {
/* this indicates we should abort quietly */
rc = ORTE_ERR_SILENT;
Expand Down Expand Up @@ -407,7 +395,7 @@ int orte_session_dir(bool create,
if (ORTE_VPID_INVALID != proc->vpid) {
if (NULL != orte_process_info.proc_session_dir) {
free(orte_process_info.proc_session_dir);
}
}
orte_process_info.proc_session_dir = strdup(fulldirpath);

/* Strip off last part of directory structure */
Expand All @@ -428,13 +416,13 @@ int orte_session_dir(bool create,
}

if (orte_debug_flag) {
opal_output(0, "procdir: %s",
opal_output(0, "procdir: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.proc_session_dir));
opal_output(0, "jobdir: %s",
opal_output(0, "jobdir: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.job_session_dir));
opal_output(0, "top: %s",
opal_output(0, "top: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.top_session_dir));
opal_output(0, "tmp: %s",
opal_output(0, "tmp: %s",
OMPI_PRINTF_FIX_STRING(orte_process_info.tmpdir_base));
}

Expand Down Expand Up @@ -503,34 +491,34 @@ orte_session_dir_cleanup(orte_jobid_t jobid)
opal_os_dirpath_destroy(tmp, false, orte_dir_check_file);

if (NULL != job_session_dir && opal_os_dirpath_is_empty(job_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_cleanup: found job session dir empty - deleting");
}
rmdir(job_session_dir);
if (orte_debug_flag) {
opal_output(0, "sess_dir_cleanup: found job session dir empty - deleting");
}
rmdir(job_session_dir);
} else {
if (orte_debug_flag) {
if (orte_debug_flag) {
if (OPAL_ERR_NOT_FOUND == opal_os_dirpath_access(job_session_dir, 0)) {
opal_output(0, "sess_dir_cleanup: job session dir does not exist");
} else {
opal_output(0, "sess_dir_cleanup: job session dir not empty - leaving");
}
}
}
goto CLEANUP;
}

if (opal_os_dirpath_is_empty(tmp)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_cleanup: found top session dir empty - deleting");
}
rmdir(tmp);
if (orte_debug_flag) {
opal_output(0, "sess_dir_cleanup: found top session dir empty - deleting");
}
rmdir(tmp);
} else {
if (orte_debug_flag) {
if (orte_debug_flag) {
if (OPAL_ERR_NOT_FOUND == opal_os_dirpath_access(tmp, 0)) {
opal_output(0, "sess_dir_cleanup: top session dir does not exist");
} else {
opal_output(0, "sess_dir_cleanup: top session dir not empty - leaving");
}
}
}
}

CLEANUP:
Expand Down Expand Up @@ -597,50 +585,50 @@ orte_session_dir_finalize(orte_process_name_t *proc)
false, orte_dir_check_file);

if (opal_os_dirpath_is_empty(proc_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found proc session dir empty - deleting");
}
rmdir(proc_session_dir);
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found proc session dir empty - deleting");
}
rmdir(proc_session_dir);
} else {
if (orte_debug_flag) {
if (orte_debug_flag) {
if (OPAL_ERR_NOT_FOUND == opal_os_dirpath_access(proc_session_dir, 0)) {
opal_output(0, "sess_dir_finalize: proc session dir does not exist");
} else {
opal_output(0, "sess_dir_finalize: proc session dir not empty - leaving");
}
}
}
goto CLEANUP;
}

if (opal_os_dirpath_is_empty(job_session_dir)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
}
rmdir(job_session_dir);
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found job session dir empty - deleting");
}
rmdir(job_session_dir);
} else {
if (orte_debug_flag) {
if (orte_debug_flag) {
if (OPAL_ERR_NOT_FOUND == opal_os_dirpath_access(job_session_dir, 0)) {
opal_output(0, "sess_dir_finalize: job session dir does not exist");
} else {
opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");
}
}
}
goto CLEANUP;
}

if (opal_os_dirpath_is_empty(tmp)) {
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
}
rmdir(tmp);
if (orte_debug_flag) {
opal_output(0, "sess_dir_finalize: found top session dir empty - deleting");
}
rmdir(tmp);
} else {
if (orte_debug_flag) {
if (orte_debug_flag) {
if (OPAL_ERR_NOT_FOUND == opal_os_dirpath_access(tmp, 0)) {
opal_output(0, "sess_dir_finalize: top session dir does not exist");
} else {
opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");
}
}
}
}

CLEANUP:
Expand Down
3 changes: 1 addition & 2 deletions orte/util/session_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ BEGIN_C_DECLS
* "false") or created (if create is "true").
*/
ORTE_DECLSPEC int orte_session_dir(bool create, char *prefix, char *hostid,
char *batchid, orte_process_name_t *proc);
orte_process_name_t *proc);

/*
* Construct the session directory name from the input parameters.
Expand All @@ -131,7 +131,6 @@ ORTE_DECLSPEC int orte_session_dir_get_name(char **fulldirpath,
char **prfx,
char **frontend,
char *hostid,
char *batchid,
orte_process_name_t *proc);

/** The orte_session_dir_finalize() function performs a cleanup of the
Expand Down