From 22f9115c824c128e206a889a966ed49d7f535063 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Fri, 12 Nov 2004 16:55:41 +0000 Subject: [PATCH] Fix component close issue with topo, coll, and io. This commit was SVN r3556. --- src/mca/base/base.h | 3 +-- src/mca/base/mca_base_component_compare.c | 3 ++- src/mca/base/mca_base_components_close.c | 23 +++++++++----------- src/mca/base/mca_base_list.c | 3 +-- src/mca/coll/base/coll_base_comm_select.c | 2 +- src/mca/coll/base/coll_base_find_available.c | 2 +- src/mca/io/base/io_base_delete.c | 2 +- src/mca/io/base/io_base_file_select.c | 2 +- src/mca/io/base/io_base_find_available.c | 2 +- src/mca/topo/base/topo_base_comm_select.c | 4 ++-- src/mca/topo/base/topo_base_find_available.c | 6 ++--- 11 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/mca/base/base.h b/src/mca/base/base.h index e9280a70cd..77fa2562c8 100644 --- a/src/mca/base/base.h +++ b/src/mca/base/base.h @@ -36,12 +36,11 @@ OBJ_CLASS_DECLARATION(mca_base_component_list_item_t); * Structure for making priority lists of components */ struct mca_base_component_priority_list_item_t { - ompi_list_item_t super; + mca_base_component_list_item_t super; int cpli_priority; bool cpli_allow_multi_user_threads; bool cpli_have_hidden_threads; - const mca_base_component_t *cpli_component; }; typedef struct mca_base_component_priority_list_item_t mca_base_component_priority_list_item_t; diff --git a/src/mca/base/mca_base_component_compare.c b/src/mca/base/mca_base_component_compare.c index e5587f1c3c..2d9a132b7d 100644 --- a/src/mca/base/mca_base_component_compare.c +++ b/src/mca/base/mca_base_component_compare.c @@ -33,7 +33,8 @@ mca_base_component_compare_priority(mca_base_component_priority_list_item_t *a, } else if (a->cpli_priority < b->cpli_priority) { return 1; } else { - return mca_base_component_compare(a->cpli_component, b->cpli_component); + return mca_base_component_compare(a->super.cli_component, + b->super.cli_component); } } diff --git a/src/mca/base/mca_base_components_close.c b/src/mca/base/mca_base_components_close.c index bb8c075a45..1518984200 100644 --- a/src/mca/base/mca_base_components_close.c +++ b/src/mca/base/mca_base_components_close.c @@ -15,7 +15,7 @@ int mca_base_components_close(int output_id, const mca_base_component_t *skip) { ompi_list_item_t *item; - mca_base_component_list_item_t *cli; + mca_base_component_priority_list_item_t *pcli, *skipped_pcli = NULL; const mca_base_component_t *component; /* Close and unload all components in the available list, except the @@ -26,8 +26,8 @@ int mca_base_components_close(int output_id, for (item = ompi_list_remove_first(components_available); NULL != item; item = ompi_list_remove_first(components_available)) { - cli = (mca_base_component_list_item_t *) item; - component = cli->cli_component; + pcli = (mca_base_component_priority_list_item_t *) item; + component = pcli->super.cli_component; if (component != skip) { @@ -47,20 +47,17 @@ int mca_base_components_close(int output_id, "mca: base: close: unloading component %s", component->mca_component_name); mca_base_component_repository_release((mca_base_component_t *) component); + free(pcli); + } else { + skipped_pcli = pcli; } - free(cli); } - /* Re-add the skipped component to the available list (see above - comment) */ + /* If we found it, re-add the skipped component to the available + list (see above comment) */ - if (NULL != skip) { - cli = malloc(sizeof(mca_base_component_list_item_t)); - if (NULL == cli) { - return OMPI_ERR_OUT_OF_RESOURCE; - } - cli->cli_component = skip; - ompi_list_append(components_available, (ompi_list_item_t *) cli); + if (NULL != skipped_pcli) { + ompi_list_append(components_available, (ompi_list_item_t *) skipped_pcli); } /* All done */ diff --git a/src/mca/base/mca_base_list.c b/src/mca/base/mca_base_list.c index 1eaefcaced..05ed21bd3a 100644 --- a/src/mca/base/mca_base_list.c +++ b/src/mca/base/mca_base_list.c @@ -26,7 +26,7 @@ OBJ_CLASS_INSTANCE(mca_base_component_list_item_t, * Class instance of the mca_base_component_priority_list_item_t class */ OBJ_CLASS_INSTANCE(mca_base_component_priority_list_item_t, - ompi_list_item_t, cpl_constructor, NULL); + mca_base_component_list_item_t, cpl_constructor, NULL); /* @@ -49,5 +49,4 @@ static void cpl_constructor(ompi_object_t *obj) cpli->cpli_priority = -1; cpli->cpli_allow_multi_user_threads = false; cpli->cpli_have_hidden_threads = false; - cpli->cpli_component = NULL; } diff --git a/src/mca/coll/base/coll_base_comm_select.c b/src/mca/coll/base/coll_base_comm_select.c index f042839658..2d25af87e7 100644 --- a/src/mca/coll/base/coll_base_comm_select.c +++ b/src/mca/coll/base/coll_base_comm_select.c @@ -312,7 +312,7 @@ static ompi_list_t *check_components(ompi_list_t *components, item != ompi_list_get_end(components); item = ompi_list_get_next(item)) { component = ((mca_base_component_priority_list_item_t *) - item)->cpli_component; + item)->super.cli_component; /* If we have a list of names, scan through it */ diff --git a/src/mca/coll/base/coll_base_find_available.c b/src/mca/coll/base/coll_base_find_available.c index 186b186f94..4007748ca3 100644 --- a/src/mca/coll/base/coll_base_find_available.c +++ b/src/mca/coll/base/coll_base_find_available.c @@ -74,7 +74,7 @@ int mca_coll_base_find_available(bool *allow_multi_user_threads, represent different versions of the coll MCA. */ entry = OBJ_NEW(mca_base_component_priority_list_item_t); - entry->cpli_component = component; + entry->super.cli_component = component; entry->cpli_priority = 0; if (OMPI_SUCCESS == init_query(component, entry)) { diff --git a/src/mca/io/base/io_base_delete.c b/src/mca/io/base/io_base_delete.c index 041b261ced..11878122de 100644 --- a/src/mca/io/base/io_base_delete.c +++ b/src/mca/io/base/io_base_delete.c @@ -193,7 +193,7 @@ static ompi_list_t *check_components(ompi_list_t *components, item != ompi_list_get_end(components); item = ompi_list_get_next(item)) { component = ((mca_base_component_priority_list_item_t *) - item)->cpli_component; + item)->super.cli_component; /* If we have a list of names, scan through it */ diff --git a/src/mca/io/base/io_base_file_select.c b/src/mca/io/base/io_base_file_select.c index c6007ea527..59e2b7e25f 100644 --- a/src/mca/io/base/io_base_file_select.c +++ b/src/mca/io/base/io_base_file_select.c @@ -238,7 +238,7 @@ static ompi_list_t *check_components(ompi_list_t *components, item != ompi_list_get_end(components); item = ompi_list_get_next(item)) { component = ((mca_base_component_priority_list_item_t *) - item)->cpli_component; + item)->super.cli_component; /* If we have a list of names, scan through it */ diff --git a/src/mca/io/base/io_base_find_available.c b/src/mca/io/base/io_base_find_available.c index 3737eea338..d121aed842 100644 --- a/src/mca/io/base/io_base_find_available.c +++ b/src/mca/io/base/io_base_find_available.c @@ -70,7 +70,7 @@ int mca_io_base_find_available(bool *allow_multi_user_threads, represent different versions of the io MCA. */ entry = OBJ_NEW(mca_base_component_priority_list_item_t); - entry->cpli_component = component; + entry->super.cli_component = component; entry->cpli_priority = 0; if (OMPI_SUCCESS == init_query(component, entry)) { diff --git a/src/mca/topo/base/topo_base_comm_select.c b/src/mca/topo/base/topo_base_comm_select.c index 6de05c7108..09b4105fbf 100644 --- a/src/mca/topo/base/topo_base_comm_select.c +++ b/src/mca/topo/base/topo_base_comm_select.c @@ -171,7 +171,7 @@ int mca_topo_base_comm_select (struct ompi_communicator_t *comm, item = ompi_list_get_next(item)) { /* convert the ompi_list_item_t returned into the proper type */ cpli = (mca_base_component_priority_list_item_t *) item; - component = (mca_topo_base_component_t *) cpli->cpli_component; + component = (mca_topo_base_component_t *) cpli->super.cli_component; ompi_output_verbose(10, mca_topo_base_output, "select: initialising %s component %s", component->topom_version.mca_type_name, @@ -219,7 +219,7 @@ int mca_topo_base_comm_select (struct ompi_communicator_t *comm, * convert the ompi_list_item_t returned into the proper type */ cpli = (mca_base_component_priority_list_item_t *) item; - component = (mca_topo_base_component_t *) cpli->cpli_component; + component = (mca_topo_base_component_t *) cpli->super.cli_component; ompi_output_verbose(10, mca_topo_base_output, "select: initialising %s component %s", component->topom_version.mca_type_name, diff --git a/src/mca/topo/base/topo_base_find_available.c b/src/mca/topo/base/topo_base_find_available.c index 848a188378..883a512535 100644 --- a/src/mca/topo/base/topo_base_find_available.c +++ b/src/mca/topo/base/topo_base_find_available.c @@ -41,13 +41,13 @@ int mca_topo_base_find_available(bool *allow_multi_user_threads, NULL != p; p = ompi_list_remove_first (&mca_topo_base_components_opened)) { entry = OBJ_NEW(mca_base_component_priority_list_item_t); - entry->cpli_component = + entry->super.cli_component = ((mca_base_component_list_item_t *)p)->cli_component; /* Now for this entry, we have to determine the thread level. Call a subroutine to do the job for us */ - if (OMPI_SUCCESS == init_query(entry->cpli_component, entry)) { + if (OMPI_SUCCESS == init_query(entry->super.cli_component, entry)) { /* Save the results in the list. The priority is not relvant at this point in time. But we save the thread arguments so that the initial selection algorithm can negotiate overall thread @@ -60,7 +60,7 @@ int mca_topo_base_find_available(bool *allow_multi_user_threads, /* The component does not want to run, so close it. Its close() has already been invoked. Close it out of the DSO repository (if it is there in the repository) */ - mca_base_component_repository_release (entry->cpli_component); + mca_base_component_repository_release(entry->super.cli_component); OBJ_RELEASE(entry); } /* Free entry from the "opened" list */