diff --git a/opal/mca/base/base.h b/opal/mca/base/base.h index 52d4acc0fd..7177bd47e6 100644 --- a/opal/mca/base/base.h +++ b/opal/mca/base/base.h @@ -60,6 +60,8 @@ OPAL_DECLSPEC OBJ_CLASS_DECLARATION(mca_base_component_priority_list_item_t); * Public variables */ OPAL_DECLSPEC extern int mca_base_param_component_path; +OPAL_DECLSPEC extern char *mca_base_system_default_path; +OPAL_DECLSPEC extern char *mca_base_user_default_path; /* * Public functions diff --git a/opal/mca/base/mca_base_close.c b/opal/mca/base/mca_base_close.c index fc31103927..362a2d64c7 100644 --- a/opal/mca/base/mca_base_close.c +++ b/opal/mca/base/mca_base_close.c @@ -33,6 +33,14 @@ int mca_base_close(void) extern bool mca_base_opened; if (mca_base_opened) { + /* release the default paths */ + if (NULL != mca_base_system_default_path) { + free(mca_base_system_default_path); + } + if (NULL != mca_base_user_default_path) { + free(mca_base_user_default_path); + } + /* Close down the component repository */ mca_base_component_repository_finalize(); diff --git a/opal/mca/base/mca_base_component_find.c b/opal/mca/base/mca_base_component_find.c index 404e24cb33..3ce3391511 100644 --- a/opal/mca/base/mca_base_component_find.c +++ b/opal/mca/base/mca_base_component_find.c @@ -250,20 +250,6 @@ static void find_dyn_components(const char *path, const char *type_name, component_file_item_t *file; opal_list_item_t *cur; char prefix[32 + MCA_BASE_MAX_TYPE_NAME_LEN], *basename; - char *system_default; - char *user_default=NULL; - - /* copy the default location definitions */ -#if OPAL_WANT_HOME_CONFIG_FILES - system_default = strdup(opal_install_dirs.pkglibdir); - asprintf(&user_default, "%s"OPAL_PATH_SEP".openmpi"OPAL_PATH_SEP"components", opal_home_directory()); -#else -# if defined(__WINDOWS__) && defined(_DEBUG) - asprintf(&system_default, "%s/debug", opal_install_dirs.pkglibdir); -# else - asprintf(&system_default, "%s", opal_install_dirs.pkglibdir); -# endif -#endif /* If path is NULL, iterate over the set of directories specified by the MCA param mca_base_component_path. If path is not NULL, then @@ -295,13 +281,15 @@ static void find_dyn_components(const char *path, const char *type_name, } if ((0 == strcmp(dir, "USER_DEFAULT") || 0 == strcmp(dir, "USR_DEFAULT")) - && NULL != user_default) { - if (0 != lt_dlforeachfile(user_default, save_filename, NULL)) { + && NULL != mca_base_user_default_path) { + if (0 != lt_dlforeachfile(mca_base_user_default_path, + save_filename, NULL)) { break; } } else if (0 == strcmp(dir, "SYS_DEFAULT") || 0 == strcmp(dir, "SYSTEM_DEFAULT")) { - if (0 != lt_dlforeachfile(system_default, save_filename, NULL)) { + if (0 != lt_dlforeachfile(mca_base_system_default_path, + save_filename, NULL)) { break; } } else { @@ -313,10 +301,6 @@ static void find_dyn_components(const char *path, const char *type_name, } while (NULL != end); } } - free(system_default); - if (NULL != user_default) { - free(user_default); - } /* Look through the list of found files and find those that match the desired framework name */ diff --git a/opal/mca/base/mca_base_open.c b/opal/mca/base/mca_base_open.c index 17a239a705..975958eb58 100644 --- a/opal/mca/base/mca_base_open.c +++ b/opal/mca/base/mca_base_open.c @@ -41,6 +41,8 @@ */ int mca_base_param_component_path = -1; bool mca_base_opened = false; +char *mca_base_system_default_path=NULL; +char *mca_base_user_default_path=NULL; /* * Private functions @@ -65,11 +67,29 @@ int mca_base_open(void) return OPAL_SUCCESS; } - /* the system and user default paths will be defined in component_find */ + /* define the system and user default paths */ +#if OPAL_WANT_HOME_CONFIG_FILES + mca_base_system_default_path = strdup(opal_install_dirs.pkglibdir); + asprintf(&mca_base_user_default_path, "%s"OPAL_PATH_SEP".openmpi"OPAL_PATH_SEP"components", opal_home_directory()); +#else +# if defined(__WINDOWS__) && defined(_DEBUG) + asprintf(&mca_base_system_default_path, "%s/debug", opal_install_dirs.pkglibdir); +# else + asprintf(&mca_base_system_default_path, "%s", opal_install_dirs.pkglibdir); +# endif +#endif + + /* see if the user wants to override the defaults */ + if (NULL == mca_base_user_default_path) { + value = strdup(mca_base_system_default_path); + } else { + asprintf(&value, "%s%c%s", mca_base_system_default_path, + OPAL_ENV_SEP, mca_base_user_default_path); + } mca_base_param_component_path = mca_base_param_reg_string_name("mca", "component_path", "Path where to look for Open MPI and ORTE components", - false, false, "SYSTEM_DEFAULT:USER_DEFAULT", NULL); + false, false, value, NULL); free(value); param_index = mca_base_param_reg_string_name("mca", "verbose", "Top-level verbosity parameter",