diff --git a/orte/mca/ess/base/ess_base_std_app.c b/orte/mca/ess/base/ess_base_std_app.c index d2a24bcb37..82f751a81a 100644 --- a/orte/mca/ess/base/ess_base_std_app.c +++ b/orte/mca/ess/base/ess_base_std_app.c @@ -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"; diff --git a/orte/mca/ess/base/ess_base_std_orted.c b/orte/mca/ess/base/ess_base_std_orted.c index b6b5b6352c..8021b07207 100644 --- a/orte/mca/ess/base/ess_base_std_orted.c +++ b/orte/mca/ess/base/ess_base_std_orted.c @@ -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"; @@ -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"; diff --git a/orte/mca/ess/base/ess_base_std_tool.c b/orte/mca/ess/base/ess_base_std_tool.c index c48f85a2b7..2206e7f611 100644 --- a/orte/mca/ess/base/ess_base_std_tool.c +++ b/orte/mca/ess/base/ess_base_std_tool.c @@ -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; diff --git a/orte/mca/ess/hnp/ess_hnp_module.c b/orte/mca/ess/hnp/ess_hnp_module.c index 0fdbbd935a..83eeb20629 100644 --- a/orte/mca/ess/hnp/ess_hnp_module.c +++ b/orte/mca/ess/hnp/ess_hnp_module.c @@ -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; @@ -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; diff --git a/orte/mca/filem/raw/filem_raw_module.c b/orte/mca/filem/raw/filem_raw_module.c index aeedef2eae..3070bc6987 100644 --- a/orte/mca/filem/raw/filem_raw_module.c +++ b/orte/mca/filem/raw/filem_raw_module.c @@ -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); diff --git a/orte/mca/schizo/ompi/schizo_ompi.c b/orte/mca/schizo/ompi/schizo_ompi.c index 27b7f7af6c..9334e66f70 100644 --- a/orte/mca/schizo/ompi/schizo_ompi.c +++ b/orte/mca/schizo/ompi/schizo_ompi.c @@ -609,7 +609,7 @@ static int setup_child(orte_job_t *jdata, param = NULL; if (ORTE_SUCCESS != (rc = orte_session_dir_get_name(¶m, &value, NULL, orte_process_info.nodename, - NULL, &child->name))) { + &child->name))) { ORTE_ERROR_LOG(rc); if (NULL != value) { free(value); diff --git a/orte/util/session_dir.c b/orte/util/session_dir.c index b0839a74d2..d6d261dd14 100644 --- a/orte/util/session_dir.c +++ b/orte/util/session_dir.c @@ -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.." */ 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, @@ -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' */ @@ -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; @@ -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; } @@ -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; } @@ -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, @@ -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; @@ -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 */ @@ -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)); } @@ -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: @@ -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: diff --git a/orte/util/session_dir.h b/orte/util/session_dir.h index 034f96fb94..6570b6e16b 100644 --- a/orte/util/session_dir.h +++ b/orte/util/session_dir.h @@ -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. @@ -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