1
1
openmpi/opal/mca/if/base/if_base_components.c
Nathan Hjelm bdedd8b0d3 Per RFC modify the behavior of mca_base_components_close to NOT close the output. Modify frameworks to always close their output and set to -1.
Reasoning: The old behavior was a little confusing. mca_base_components_open does not open an output stream so it is a little unexpected that mca_base_components_close does. To add to this several frameworks (that don't use mca_base_components_close) failed to close their output in the framework close function and others closed their output a second time. This change is an improvement to the symantics of mca_base_components_open/close as they are now symetric in their functionality.

This commit was SVN r27570.
2012-11-06 19:09:26 +00:00

122 строки
3.5 KiB
C

/*
* Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#include "opal_config.h"
#include "opal/constants.h"
#include "opal/util/output.h"
#include "opal/mca/mca.h"
#include "opal/mca/if/if.h"
#include "opal/mca/if/base/base.h"
#include "opal/mca/if/base/static-components.h"
int opal_if_base_output=-1;
opal_list_t opal_if_components;
static bool already_done = false;
/* instantiate the global list of interfaces */
opal_list_t opal_if_list;
bool opal_if_do_not_resolve;
bool opal_if_retain_loopback;
/* instance the opal_if_t object */
OBJ_CLASS_INSTANCE(opal_if_t, opal_list_item_t, NULL, NULL);
int opal_if_base_open(void)
{
int i, ret;
mca_base_component_list_item_t *cli;
if (already_done) {
return OPAL_SUCCESS;
}
already_done = true;
/* setup the global list */
OBJ_CONSTRUCT(&opal_if_list, opal_list_t);
mca_base_param_reg_int_name("if", "base_verbose",
"Provide verbose output if greater than 0",
false, false, -1, &ret);
if (0 < ret) {
opal_if_base_output = opal_output_open(NULL);
opal_output_set_verbosity(opal_if_base_output, ret);
}
mca_base_param_reg_int_name("opal", "if_do_not_resolve",
"If nonzero, do not attempt to resolve interfaces",
false, false, (int)false, &ret);
opal_if_do_not_resolve = OPAL_INT_TO_BOOL(ret);
mca_base_param_reg_int_name("opal", "if_retain_loopback",
"If nonzero, retain loopback interfaces",
false, false, (int)false, &ret);
opal_if_retain_loopback = OPAL_INT_TO_BOOL(ret);
OBJ_CONSTRUCT(&opal_if_components, opal_list_t);
for (i = 0 ; mca_if_base_static_components[i] != NULL ; ++i) {
opal_if_base_component_t *component =
(opal_if_base_component_t*)
mca_if_base_static_components[i];
/* Save it in a global list for ompi_info */
cli = OBJ_NEW(mca_base_component_list_item_t);
cli->cli_component = mca_if_base_static_components[i];
opal_list_append(&opal_if_components, &cli->super);
opal_output_verbose(5, opal_if_base_output,
"if:base: opening component %s",
component->component.mca_component_name);
if (NULL != component->component.mca_open_component) {
ret = component->component.mca_open_component();
if (OPAL_SUCCESS != ret) continue;
}
if (NULL != mca_if_base_static_components[i]->mca_close_component) {
mca_if_base_static_components[i]->mca_close_component();
}
}
return OPAL_SUCCESS;
}
int opal_if_base_close(void)
{
opal_list_item_t *item;
if (!already_done) {
return OPAL_SUCCESS;
}
already_done = false;
for (item = opal_list_remove_first(&opal_if_list);
NULL != item;
item = opal_list_remove_first(&opal_if_list)) {
OBJ_RELEASE(item);
}
OBJ_DESTRUCT(&opal_if_list);
for (item = opal_list_remove_first(&opal_if_components);
NULL != item;
item = opal_list_remove_first(&opal_if_components)) {
OBJ_RELEASE(item);
}
OBJ_DESTRUCT(&opal_if_components);
/* Close the framework output */
opal_output_close (opal_if_base_output);
opal_if_base_output = -1;
return OPAL_SUCCESS;
}