⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 session_dir.c

📁 MPI stands for the Message Passing Interface. Written by the MPI Forum (a large committee comprising
💻 C
📖 第 1 页 / 共 2 页
字号:
        if(dbl_check_prefix) {            dbl_check_prefix = false;            goto try_again;        }        else {            goto cleanup;        }    }    /*     * Now that we have the full path, go ahead and create it if necessary     */    if( create ) {        if( ORTE_SUCCESS != (rtn = orte_create_dir(fulldirpath) ) ) {            return_code = rtn;                        if(dbl_check_prefix) {                dbl_check_prefix = false;                goto try_again;            }            else {                goto cleanup;            }        }    }    /*     * if we are not creating, then just verify that the path is OK     */    else {        if( ORTE_SUCCESS != (rtn = 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 {                goto cleanup;            }        }    }    return_code = ORTE_SUCCESS;    /*     * If we are creating the directory tree, the overwrite the     * global structure fields     */    if (create) {    	if (NULL != orte_process_info.tmpdir_base) {    	    free(orte_process_info.tmpdir_base);    	    orte_process_info.tmpdir_base = NULL;    	}    	if (NULL != orte_process_info.top_session_dir) {    	    free(orte_process_info.top_session_dir);    	    orte_process_info.top_session_dir = NULL;    	}    }    /*      * Update some of the global structures if they are empty     */    if (NULL == orte_process_info.tmpdir_base)        orte_process_info.tmpdir_base = strdup(prefix);    if (NULL == orte_process_info.top_session_dir)        orte_process_info.top_session_dir = strdup(frontend);        /*     * Set the process session directory     */    if (NULL != proc) {    	if (create) { /* overwrite if creating */    	    if (NULL != orte_process_info.proc_session_dir) {                free(orte_process_info.proc_session_dir);                orte_process_info.proc_session_dir = NULL;    	    }    	}    	if (NULL == orte_process_info.proc_session_dir) {    	    orte_process_info.proc_session_dir = strdup(fulldirpath);    	}        /* Strip off last part of directory structure */        sav = opal_dirname(fulldirpath);        free(fulldirpath);        fulldirpath = sav;        sav = NULL;    }    /*     * Set the job session directory     */    if (NULL != job) {    	if (create) { /* overwrite if creating */    	    if (NULL != orte_process_info.job_session_dir) {                free(orte_process_info.job_session_dir);                orte_process_info.job_session_dir = NULL;    	    }    	}    	if (NULL == orte_process_info.job_session_dir) {    	    orte_process_info.job_session_dir = strdup(fulldirpath);    	}        /* Strip off last part of directory structure */        sav = opal_dirname(fulldirpath);        free(fulldirpath);        fulldirpath = sav;        sav = NULL;    }    /*     * Set the universe session directory     */    if (create) { /* overwrite if creating */    	if (NULL != orte_process_info.universe_session_dir) {    	    free(orte_process_info.universe_session_dir);    	    orte_process_info.universe_session_dir = NULL;    	}    }    if (NULL == orte_process_info.universe_session_dir) {        orte_process_info.universe_session_dir = strdup(fulldirpath);    }    if (orte_debug_flag) {    	opal_output(0, "procdir: %s",                     OMPI_PRINTF_FIX_STRING(orte_process_info.proc_session_dir));    	opal_output(0, "jobdir: %s",                     OMPI_PRINTF_FIX_STRING(orte_process_info.job_session_dir));    	opal_output(0, "unidir: %s",                     OMPI_PRINTF_FIX_STRING(orte_process_info.universe_session_dir));    	opal_output(0, "top: %s",                     OMPI_PRINTF_FIX_STRING(orte_process_info.top_session_dir));    	opal_output(0, "tmp: %s",                     OMPI_PRINTF_FIX_STRING(orte_process_info.tmpdir_base));    } cleanup:    if(NULL != fulldirpath)        free(fulldirpath);    if(NULL != frontend)        free(frontend);    if(NULL != sav)        free(sav);    return return_code;}/* * A job has aborted - so force cleanup of the session directory */intorte_session_dir_cleanup(orte_jobid_t jobid){    int rc;    char *tmp;    char *job, *job_session_dir;    /* need to setup the top_session_dir with the prefix */    tmp = opal_os_path(false,                       orte_process_info.tmpdir_base,                       orte_process_info.top_session_dir, NULL);        /* define the proc and job session directories for this process */    if (ORTE_SUCCESS != (rc = orte_ns.convert_jobid_to_string(&job, jobid))) {        ORTE_ERROR_LOG(rc);        free(tmp);        return rc;    }    job_session_dir = opal_os_path( false, orte_process_info.universe_session_dir,                                    job, NULL );    if( NULL == job_session_dir ) {        ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);        free(tmp);        free(job);        return ORTE_ERR_OUT_OF_RESOURCE;    }        opal_os_dirpath_destroy(job_session_dir,                            true, orte_dir_check_file);    opal_os_dirpath_destroy(orte_process_info.universe_session_dir,                            false, orte_dir_check_file);    opal_os_dirpath_destroy(tmp,                            false, orte_dir_check_file);    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);    } else {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");    	}        goto CLEANUP;    }    if (opal_os_dirpath_is_empty(orte_process_info.universe_session_dir)) {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: found univ session dir empty - deleting");    	}    	rmdir(orte_process_info.universe_session_dir);    } else {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: univ 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);    } else {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");    	}    }CLEANUP:    free(tmp);    free(job);    free(job_session_dir);    return ORTE_SUCCESS;}intorte_session_dir_finalize(orte_process_name_t *proc){    int rc;    char *tmp;    char *job, *job_session_dir, *vpid, *proc_session_dir;    /* need to setup the top_session_dir with the prefix */    tmp = opal_os_path(false,                       orte_process_info.tmpdir_base,                       orte_process_info.top_session_dir, NULL);        /* define the proc and job session directories for this process */    if (ORTE_SUCCESS != (rc = orte_ns.get_jobid_string(&job, proc))) {        ORTE_ERROR_LOG(rc);        free(tmp);        return rc;    }    if (ORTE_SUCCESS != (rc = orte_ns.get_vpid_string(&vpid, proc))) {        ORTE_ERROR_LOG(rc);        free(tmp);        free(job);        return rc;    }    job_session_dir = opal_os_path( false, orte_process_info.universe_session_dir,                                    job, NULL );    if( NULL == job_session_dir ) {        ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);        free(tmp);        free(job);        free(vpid);        return ORTE_ERR_OUT_OF_RESOURCE;    }    proc_session_dir = opal_os_path( false, job_session_dir, vpid, NULL );    if( NULL == proc_session_dir ) {        ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);        free(tmp);        free(job);        free(vpid);        free(job_session_dir);        return ORTE_ERR_OUT_OF_RESOURCE;    }        opal_os_dirpath_destroy(proc_session_dir,                            false, orte_dir_check_file);    opal_os_dirpath_destroy(job_session_dir,                            false, orte_dir_check_file);    opal_os_dirpath_destroy(orte_process_info.universe_session_dir,                            false, orte_dir_check_file);    opal_os_dirpath_destroy(tmp,                            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);    } else {    	if (orte_debug_flag) {    	    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);    } else {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: job session dir not empty - leaving");    	}        goto CLEANUP;    }    if (opal_os_dirpath_is_empty(orte_process_info.universe_session_dir)) {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: found univ session dir empty - deleting");    	}    	rmdir(orte_process_info.universe_session_dir);    } else {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: univ 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);    } else {    	if (orte_debug_flag) {    	    opal_output(0, "sess_dir_finalize: top session dir not empty - leaving");    	}    }CLEANUP:    free(tmp);    free(job);    free(vpid);    free(job_session_dir);    free(proc_session_dir);    return ORTE_SUCCESS;}static bool orte_dir_check_file(const char *root, const char *path) {    /*     * Keep:     *  - files starting with "output-"     *  - universe contact (universe-setup.txt)     */    if( (0 == strncmp(path, "output-", strlen("output-"))) ||        (0 == strcmp(path,  "universe-setup.txt"))) {        return false;    }    return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -