What: On close some frameworks either:
  1) close their output twice (calling both opal_output_close and 
mca_base_components_close), or
  2) don't close their output.

This patch ensures that all frameworks that call opal_output_open have exactly 
one call to either opal_output_close OR mca_base_components_close.

Why: I am working on cleaning up the MCA system in preparation for adding 
support for MPI_T_cvar_write. I came across this potential problem and figured 
it should probably be fixed.

When: Since this patch shouldn't take long to review I am setting a very short 
timeout: tomorrow (Nov 2), 12:00pm MDT.

Questions? Comments?

-Nathan Hjelm
HPC-3, LANL
diff --git a/ompi/mca/btl/base/btl_base_close.c 
b/ompi/mca/btl/base/btl_base_close.c
index b3632ab..21ffb90 100644
--- a/ompi/mca/btl/base/btl_base_close.c
+++ b/ompi/mca/btl/base/btl_base_close.c
@@ -58,11 +58,9 @@ int mca_btl_base_close(void)

     /* Close all remaining opened components (may be one if this is a
        OMPI RTE program, or [possibly] multiple if this is ompi_info) */
-  
-    if (0 != opal_list_get_size(&mca_btl_base_components_opened)) {
-        mca_base_components_close(mca_btl_base_output, 
-                                  &mca_btl_base_components_opened, NULL);
-    }
+
+    mca_base_components_close(mca_btl_base_output,
+                              &mca_btl_base_components_opened, NULL);

     /* cleanup */
     if(NULL != mca_btl_base_include)
diff --git a/ompi/mca/fbtl/base/fbtl_base_close.c 
b/ompi/mca/fbtl/base/fbtl_base_close.c
index c838408..f8c45ab 100644
--- a/ompi/mca/fbtl/base/fbtl_base_close.c
+++ b/ompi/mca/fbtl/base/fbtl_base_close.c
@@ -45,10 +45,12 @@ int mca_fbtl_base_close(void)
                                   &mca_fbtl_base_components_available, NULL);
         OBJ_DESTRUCT(&mca_fbtl_base_components_available);
         mca_fbtl_base_components_available_valid = false;
+    } else {
+        /* Close the output stream for this framework if it is open */
+        opal_output_close (mca_fbtl_base_output);
     }

-    /* Close the output stream for this framework */
-    opal_output_close (mca_fbtl_base_output);
+    mca_fbtl_base_output = -1;

     /* All done */

diff --git a/ompi/mca/fcoll/base/fcoll_base_close.c 
b/ompi/mca/fcoll/base/fcoll_base_close.c
index 5f2ef3e..34295b7 100644
--- a/ompi/mca/fcoll/base/fcoll_base_close.c
+++ b/ompi/mca/fcoll/base/fcoll_base_close.c
@@ -46,10 +46,12 @@ int mca_fcoll_base_close(void)
                                   &mca_fcoll_base_components_available, NULL);
         OBJ_DESTRUCT(&mca_fcoll_base_components_available);
         mca_fcoll_base_components_available_valid = false;
+    } else {
+        /* Close the output stream for this framework if it is open */
+        opal_output_close (mca_fcoll_base_output);
     }

-    /* Close the output stream for this framework */
-    opal_output_close (mca_fcoll_base_output);
+    mca_fcoll_base_output = -1;

     /* All done */

diff --git a/ompi/mca/fs/base/fs_base_close.c b/ompi/mca/fs/base/fs_base_close.c
index 3dc55bf..68cc2b5 100644
--- a/ompi/mca/fs/base/fs_base_close.c
+++ b/ompi/mca/fs/base/fs_base_close.c
@@ -46,10 +46,12 @@ int mca_fs_base_close(void)
                                   &mca_fs_base_components_available, NULL);
         OBJ_DESTRUCT(&mca_fs_base_components_available);
         mca_fs_base_components_available_valid = false;
+    } else {
+        /* Close the output stream for this framework if it is open */
+        opal_output_close (mca_fs_base_output);
     }

-    /* Close the output stream for this framework */
-    opal_output_close (mca_fs_base_output);
+    mca_fs_base_output = -1;

     /* All done */

diff --git a/ompi/mca/io/base/io_base_close.c b/ompi/mca/io/base/io_base_close.c
index 9038663..7f408d6 100644
--- a/ompi/mca/io/base/io_base_close.c
+++ b/ompi/mca/io/base/io_base_close.c
@@ -44,8 +44,12 @@ int mca_io_base_close(void)
                                   &mca_io_base_components_available, NULL);
         OBJ_DESTRUCT(&mca_io_base_components_available);
         mca_io_base_components_available_valid = false;
+    } else {
+        opal_output_close (mca_io_base_output);
     }

+    mca_io_base_output = -1;
+
     /* All done */

     return OMPI_SUCCESS;
diff --git a/ompi/mca/op/base/op_base_close.c b/ompi/mca/op/base/op_base_close.c
index 83755be..543b52a 100644
--- a/ompi/mca/op/base/op_base_close.c
+++ b/ompi/mca/op/base/op_base_close.c
@@ -44,8 +44,12 @@ int ompi_op_base_close(void)
                                   NULL);
         OBJ_DESTRUCT(&ompi_op_base_components_available);
         ompi_op_base_components_available_valid = false;
+    } else {
+        opal_output_close (ompi_op_base_output);
     }

+    ompi_op_base_output = -1;
+
     /* All done */

     return OMPI_SUCCESS;
diff --git a/ompi/mca/sharedfp/base/sharedfp_base_close.c 
b/ompi/mca/sharedfp/base/sharedfp_base_close.c
index 86cf686..f888467 100644
--- a/ompi/mca/sharedfp/base/sharedfp_base_close.c
+++ b/ompi/mca/sharedfp/base/sharedfp_base_close.c
@@ -46,10 +46,12 @@ int mca_sharedfp_base_close(void)
                                   &mca_sharedfp_base_components_available, 
NULL);
         OBJ_DESTRUCT(&mca_sharedfp_base_components_available);
         mca_sharedfp_base_components_available_valid = false;
+    } else {
+        /* Close the output stream for this framework */
+        opal_output_close (mca_sharedfp_base_output);
     }

-    /* Close the output stream for this framework */
-    opal_output_close (mca_sharedfp_base_output);
+    mca_sharedfp_base_output = -1;

     /* All done */

diff --git a/ompi/mca/topo/base/topo_base_close.c 
b/ompi/mca/topo/base/topo_base_close.c
index 8089a58..9ca6664 100644
--- a/ompi/mca/topo/base/topo_base_close.c
+++ b/ompi/mca/topo/base/topo_base_close.c
@@ -41,10 +41,12 @@ int mca_topo_base_close(void)
         mca_base_components_close (mca_topo_base_output,
                                 &mca_topo_base_components_available, NULL);
         mca_topo_base_components_available_valid = false;
+    } else {
+        /* Close the output stream for this framework if it is open */
+        opal_output_close (mca_topo_base_output);
     }

-    /* Close the output stream for this framework */
-    opal_output_close (mca_topo_base_output);
+    mca_topo_base_output = -1;

     /*
      * All done
diff --git a/opal/mca/event/base/event_base_close.c 
b/opal/mca/event/base/event_base_close.c
index 6ecb89f..cdfc013 100644
--- a/opal/mca/event/base/event_base_close.c
+++ b/opal/mca/event/base/event_base_close.c
@@ -31,6 +31,11 @@ int opal_event_base_close(void)
     }
     OBJ_DESTRUCT(&opal_event_components);

+    if (-1 != opal_event_base_output) {
+        opal_output_close (opal_event_base_output);
+        opal_event_base_output = -1;
+    }
+
     /* All done */
     return OPAL_SUCCESS;
 }
diff --git a/opal/mca/hwloc/base/hwloc_base_close.c 
b/opal/mca/hwloc/base/hwloc_base_close.c
index fa22c96..068ea54 100644
--- a/opal/mca/hwloc/base/hwloc_base_close.c
+++ b/opal/mca/hwloc/base/hwloc_base_close.c
@@ -40,6 +40,11 @@ int opal_hwloc_base_close(void)
             hwloc_bitmap_free(opal_hwloc_my_cpuset);
             opal_hwloc_my_cpuset = NULL;
         }
+
+        if (-1 != opal_hwloc_base_output) {
+            opal_output_close (opal_hwloc_base_output);
+            opal_hwloc_base_output = -1;
+        }
     }
 #endif

diff --git a/opal/mca/if/base/if_base_components.c 
b/opal/mca/if/base/if_base_components.c
index 906c971..1be27fa 100644
--- a/opal/mca/if/base/if_base_components.c
+++ b/opal/mca/if/base/if_base_components.c
@@ -112,6 +112,11 @@ int opal_if_base_close(void)
     }
     OBJ_DESTRUCT(&opal_if_components);

+    if (-1 != opal_if_base_output) {
+        opal_output_close (opal_if_base_output);
+        opal_if_base_output = -1;
+    }
+
     return OPAL_SUCCESS;
 }

diff --git a/opal/mca/installdirs/base/installdirs_base_components.c 
b/opal/mca/installdirs/base/installdirs_base_components.c
index 0d9d1c7..7aab79d 100644
--- a/opal/mca/installdirs/base/installdirs_base_components.c
+++ b/opal/mca/installdirs/base/installdirs_base_components.c
@@ -19,7 +19,6 @@
 #include "opal/mca/installdirs/base/base.h"
 #include "opal/mca/installdirs/base/static-components.h"

-int opal_installdirs_base_output;
 opal_install_dirs_t opal_install_dirs;
 opal_list_t opal_installdirs_components;

diff --git a/opal/mca/memchecker/base/memchecker_base_close.c 
b/opal/mca/memchecker/base/memchecker_base_close.c
index fbfa7cd..55fb455 100644
--- a/opal/mca/memchecker/base/memchecker_base_close.c
+++ b/opal/mca/memchecker/base/memchecker_base_close.c
@@ -20,7 +20,8 @@ int opal_memchecker_base_close(void)
 {
     /* Close all components that are still open (this should only
        happen during laminfo). */
-    mca_base_components_close(0, &opal_memchecker_base_components_opened, 
NULL);
+    mca_base_components_close(opal_memchecker_base_output,
+                              &opal_memchecker_base_components_opened, NULL);
     OBJ_DESTRUCT(&opal_memchecker_base_components_opened);

     /* All done */
diff --git a/opal/mca/shmem/base/shmem_base_close.c 
b/opal/mca/shmem/base/shmem_base_close.c
index a4755ee..e24acad 100644
--- a/opal/mca/shmem/base/shmem_base_close.c
+++ b/opal/mca/shmem/base/shmem_base_close.c
@@ -46,8 +46,12 @@ opal_shmem_base_close(void)
                                   &opal_shmem_base_components_opened, NULL);
         OBJ_DESTRUCT(&opal_shmem_base_components_opened);
         opal_shmem_base_components_opened_valid = false;
+    } else {
+        opal_output_close (opal_shmem_base_output);
     }

+    opal_shmem_base_output = -1;
+
     /* all done */
     return OPAL_SUCCESS;
 }
diff --git a/orte/mca/db/base/db_base_close.c b/orte/mca/db/base/db_base_close.c
index 719e397..9e51124 100644
--- a/orte/mca/db/base/db_base_close.c
+++ b/orte/mca/db/base/db_base_close.c
@@ -33,7 +33,7 @@ orte_db_base_close(void)
                               &orte_db_base.available_components, NULL);

     OBJ_DESTRUCT(&orte_db_base.available_components);
-    opal_output_close(orte_db_base.output);
+
     return ORTE_SUCCESS;
 }

diff --git a/orte/mca/odls/base/odls_base_close.c 
b/orte/mca/odls/base/odls_base_close.c
index 036496b..165a69e 100644
--- a/orte/mca/odls/base/odls_base_close.c
+++ b/orte/mca/odls/base/odls_base_close.c
@@ -53,11 +53,6 @@ int orte_odls_base_close(void)
     }
     OBJ_RELEASE(orte_local_children);

-    /* if no components are available, then punt */
-    if (!orte_odls_base.components_available) {
-        return ORTE_SUCCESS;
-    }
-    
     /* Close all available components (only one in this case)  */

     mca_base_components_close(orte_odls_globals.output, 

Reply via email to