From 27be73c6fb14df3ab4e5f6f24365d96d5ca6c40b Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Wed, 19 Nov 2014 13:31:31 -0800 Subject: [PATCH] Allow callers to dstore.open to not request a specific list of desired components, but just take the highest priority one that is available --- opal/mca/dstore/base/dstore_base_stubs.c | 56 ++++++++++++++++-------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/opal/mca/dstore/base/dstore_base_stubs.c b/opal/mca/dstore/base/dstore_base_stubs.c index ebba7006fd..6e28c1e81c 100644 --- a/opal/mca/dstore/base/dstore_base_stubs.c +++ b/opal/mca/dstore/base/dstore_base_stubs.c @@ -34,29 +34,49 @@ int opal_dstore_base_open(const char *name, char* desired_components, opal_list_ int i; mca_base_component_list_item_t* cli; char** tokens; - tokens = opal_argv_split(desired_components, ','); - for (i = 0; NULL != tokens[i]; i++) { - OPAL_LIST_FOREACH(cli, &opal_dstore_base.available_components, mca_base_component_list_item_t) { - if (0 == strncmp(tokens[i], cli->cli_component->mca_component_name, strlen(tokens[i]))) { - if (NULL != ((opal_dstore_base_component_t*)cli->cli_component)->create_handle && NULL != (mod = ((opal_dstore_base_component_t*)cli->cli_component)->create_handle(attrs))) { - /* have our module, so create a new dstore_handle */ - hdl = OBJ_NEW(opal_dstore_handle_t); - if (NULL != name) { - hdl->name = strdup(name); + + if (NULL != desired_components) { + tokens = opal_argv_split(desired_components, ','); + for (i = 0; NULL != tokens[i]; i++) { + OPAL_LIST_FOREACH(cli, &opal_dstore_base.available_components, mca_base_component_list_item_t) { + if (0 == strncmp(tokens[i], cli->cli_component->mca_component_name, strlen(tokens[i]))) { + if (NULL != ((opal_dstore_base_component_t*)cli->cli_component)->create_handle && NULL != (mod = ((opal_dstore_base_component_t*)cli->cli_component)->create_handle(attrs))) { + /* have our module, so create a new dstore_handle */ + hdl = OBJ_NEW(opal_dstore_handle_t); + if (NULL != name) { + hdl->name = strdup(name); + } + hdl->module = mod; + hdl->storage_component = (opal_dstore_base_component_t*)cli->cli_component; + if (0 > (index = opal_pointer_array_add(&opal_dstore_base.handles, hdl))) { + OPAL_ERROR_LOG(index); + OBJ_RELEASE(hdl); + } + opal_argv_free(tokens); + return index; } - hdl->module = mod; - hdl->storage_component = (opal_dstore_base_component_t*)cli->cli_component; - if (0 > (index = opal_pointer_array_add(&opal_dstore_base.handles, hdl))) { - OPAL_ERROR_LOG(index); - OBJ_RELEASE(hdl); - } - opal_argv_free(tokens); - return index; } } } + opal_argv_free(tokens); + } else { + OPAL_LIST_FOREACH(cli, &opal_dstore_base.available_components, mca_base_component_list_item_t) { + if (NULL != ((opal_dstore_base_component_t*)cli->cli_component)->create_handle && NULL != (mod = ((opal_dstore_base_component_t*)cli->cli_component)->create_handle(attrs))) { + /* have our module, so create a new dstore_handle */ + hdl = OBJ_NEW(opal_dstore_handle_t); + if (NULL != name) { + hdl->name = strdup(name); + } + hdl->module = mod; + hdl->storage_component = (opal_dstore_base_component_t*)cli->cli_component; + if (0 > (index = opal_pointer_array_add(&opal_dstore_base.handles, hdl))) { + OPAL_ERROR_LOG(index); + OBJ_RELEASE(hdl); + } + return index; + } + } } - opal_argv_free(tokens); /* if we get here, then we were unable to create a module * for this scope