1
1

Fix a bug reported by Rainer whereby we could free and reuse an address if the user specified the tmp dir base. After discussing with Josh, we also removed the code that had us retry creation of the session dir (using default values) if the user-specified value didn't work for some reason. Adhering to OMPI standard practices, we abort if the user-specified value doesn't work.

This commit was SVN r22255.
Этот коммит содержится в:
Ralph Castain 2009-12-03 01:57:35 +00:00
родитель f0303a8b25
Коммит 3a72ee9dca

Просмотреть файл

@ -365,101 +365,58 @@ int orte_session_dir(bool create,
char *fulldirpath = NULL, char *fulldirpath = NULL,
*frontend = NULL, *frontend = NULL,
*sav = NULL; *sav = NULL;
int return_code = ORTE_SUCCESS, rtn; int rc = ORTE_SUCCESS;
/* This indicates if the prefix was set, and so if it fails then we char *local_prefix = NULL;
* should try with the default prefixes.*/
bool dbl_check_prefix = false;
if( NULL != prefix) /* use the specified prefix, if one was given */
dbl_check_prefix = true; if (NULL != prefix) {
local_prefix = strdup(prefix);
try_again:
/*
* If the first attempt at the path creation failed, try with a null
* prefix. unless the original prefix was null, then we fail.
*/
if(!dbl_check_prefix && /* an indicator that we are trying a second time */
NULL != prefix) {
free(prefix);
prefix = NULL;
} }
/* /*
* Get the session directory full name * Get the session directory full name
* First try it with the specified prefix.
*/ */
if( ORTE_SUCCESS != ( rtn = orte_session_dir_get_name(&fulldirpath, if( ORTE_SUCCESS != ( rc = orte_session_dir_get_name(&fulldirpath,
&prefix, &local_prefix,
&frontend, &frontend,
hostid, hostid,
batchid, proc) ) ) { batchid, proc) ) ) {
if (ORTE_ERR_FATAL == rtn) { if (ORTE_ERR_FATAL == rc) {
/* this indicates we definitely need to abort, so /* this indicates we should abort quietly */
* don't try the NULL prefix rc = ORTE_ERR_SILENT;
*/
return_code = ORTE_ERR_SILENT;
goto cleanup; goto cleanup;
} }
return_code = rtn; /* otherwise, bark a little first */
/* ORTE_ERROR_LOG(rc);
* If the first attempt at the path creation failed, try with a null
* prefix. unless the original prefix was null, then we fail :(
*/
if(dbl_check_prefix) {
dbl_check_prefix = false;
goto try_again;
}
else {
ORTE_ERROR_LOG(return_code);
goto cleanup; goto cleanup;
} }
}
/* /*
* Now that we have the full path, go ahead and create it if necessary * Now that we have the full path, go ahead and create it if necessary
*/ */
if( create ) { if( create ) {
if( ORTE_SUCCESS != (rtn = orte_create_dir(fulldirpath) ) ) { if( ORTE_SUCCESS != (rc = orte_create_dir(fulldirpath) ) ) {
return_code = rtn; ORTE_ERROR_LOG(rc);
if(dbl_check_prefix) {
dbl_check_prefix = false;
goto try_again;
}
else {
ORTE_ERROR_LOG(return_code);
goto cleanup; goto cleanup;
} }
} }
}
/* /*
* if we are not creating, then just verify that the path is OK * if we are not creating, then just verify that the path is OK
*/ */
else { else {
if( ORTE_SUCCESS != (rtn = opal_os_dirpath_access(fulldirpath, 0) )) { if( ORTE_SUCCESS != (rc = opal_os_dirpath_access(fulldirpath, 0) )) {
/* It is not valid so we give up and return an error */
return_code = rtn;
if(dbl_check_prefix) {
dbl_check_prefix = false;
goto try_again;
}
else {
/* it is okay for the path not to be found - don't error /* it is okay for the path not to be found - don't error
* log that case, but do error log others * log that case, but do error log others
*/ */
if (ORTE_ERR_NOT_FOUND != return_code) { if (ORTE_ERR_NOT_FOUND != rc) {
ORTE_ERROR_LOG(return_code); ORTE_ERROR_LOG(rc);
} }
goto cleanup; goto cleanup;
} }
} }
}
return_code = ORTE_SUCCESS;
/* /*
* If we are creating the directory tree, the overwrite the * If we are creating the directory tree, then force overwrite of the
* global structure fields * global structure fields
*/ */
if (create) { if (create) {
@ -477,12 +434,11 @@ int orte_session_dir(bool create,
* Update some of the global structures if they are empty * Update some of the global structures if they are empty
*/ */
if (NULL == orte_process_info.tmpdir_base) if (NULL == orte_process_info.tmpdir_base)
orte_process_info.tmpdir_base = strdup(prefix); orte_process_info.tmpdir_base = strdup(local_prefix);
if (NULL == orte_process_info.top_session_dir) if (NULL == orte_process_info.top_session_dir)
orte_process_info.top_session_dir = strdup(frontend); orte_process_info.top_session_dir = strdup(frontend);
/* /*
* Set the process session directory * Set the process session directory
*/ */
@ -530,13 +486,13 @@ int orte_session_dir(bool create,
OMPI_PRINTF_FIX_STRING(orte_process_info.tmpdir_base)); OMPI_PRINTF_FIX_STRING(orte_process_info.tmpdir_base));
} }
cleanup: cleanup:
if(NULL != fulldirpath) if(NULL != fulldirpath)
free(fulldirpath); free(fulldirpath);
if(NULL != frontend) if(NULL != frontend)
free(frontend); free(frontend);
return return_code; return rc;
} }
/* /*