diff --git a/ompi/mca/bml/base/base.h b/ompi/mca/bml/base/base.h index 4bfeeeda8f..00a44c5d77 100644 --- a/ompi/mca/bml/base/base.h +++ b/ompi/mca/bml/base/base.h @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2006 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -59,6 +60,7 @@ OMPI_DECLSPEC int mca_bml_base_ft_event(int state); /* * Globals */ +extern int mca_bml_base_already_opened; OMPI_DECLSPEC extern int mca_bml_base_output; OMPI_DECLSPEC extern mca_bml_base_component_t mca_bml_component; OMPI_DECLSPEC extern opal_list_t mca_bml_base_components_available; diff --git a/ompi/mca/bml/base/bml_base_close.c b/ompi/mca/bml/base/bml_base_close.c index afcc4a8ebc..f90b28d790 100644 --- a/ompi/mca/bml/base/bml_base_close.c +++ b/ompi/mca/bml/base/bml_base_close.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2006 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -23,10 +24,12 @@ int mca_bml_base_close( void ) { int rc; + if (mca_bml_base_already_opened <= 0) { + return OMPI_ERROR; + } else if (--mca_bml_base_already_opened > 0) { + return OMPI_SUCCESS; + } - if(OMPI_SUCCESS != (rc = mca_btl_base_close())) - return rc; - - return OMPI_SUCCESS; + return mca_btl_base_close(); } diff --git a/ompi/mca/bml/base/bml_base_open.c b/ompi/mca/bml/base/bml_base_open.c index db5399379c..88b801cf37 100644 --- a/ompi/mca/bml/base/bml_base_open.c +++ b/ompi/mca/bml/base/bml_base_open.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2006 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -28,6 +29,7 @@ #include "ompi/mca/bml/base/static-components.h" #include "opal/mca/base/base.h" +int mca_bml_base_already_opened = 0; opal_list_t mca_bml_base_components_available; #if OMPI_ENABLE_DEBUG_RELIABILITY @@ -36,8 +38,13 @@ double mca_bml_base_error_rate_ceiling; int mca_bml_base_error_count; #endif -int mca_bml_base_open( void ) { - +int mca_bml_base_open(void) +{ + /* See if we've already been here */ + if (++mca_bml_base_already_opened > 1) { + return OMPI_SUCCESS; + } + if(OMPI_SUCCESS != mca_base_components_open("bml", 0, mca_bml_base_static_components, &mca_bml_base_components_available, diff --git a/ompi/mca/bml/r2/bml_r2.c b/ompi/mca/bml/r2/bml_r2.c index c8f6bbe1fb..493c474b36 100644 --- a/ompi/mca/bml/r2/bml_r2.c +++ b/ompi/mca/bml/r2/bml_r2.c @@ -12,7 +12,7 @@ * All rights reserved. * Copyright (c) 2007 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -646,7 +646,8 @@ int mca_bml_r2_finalize( void ) mca_bml_r2.btl_progress = NULL; } - mca_btl_base_close(); + /* Do not close the BTL base here; the BML upper layer will take + care of that. */ return OMPI_SUCCESS; } diff --git a/ompi/mca/btl/base/btl_base_close.c b/ompi/mca/btl/base/btl_base_close.c index 09569eef63..cee6cb6154 100644 --- a/ompi/mca/btl/base/btl_base_close.c +++ b/ompi/mca/btl/base/btl_base_close.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -36,10 +36,8 @@ int mca_btl_base_close(void) if( mca_btl_base_already_opened <= 0 ) { return OMPI_ERROR; - } else { - if( --mca_btl_base_already_opened > 0 ) { - return OMPI_SUCCESS; - } + } else if (--mca_btl_base_already_opened > 0) { + return OMPI_SUCCESS; } /* disable event processing while cleaning up btls */ opal_event_disable();