summaryrefslogtreecommitdiffstats
path: root/src/H5.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2015-09-14 03:58:59 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2015-09-14 03:58:59 (GMT)
commit102337449220dfc29be1cce29147704b9c760832 (patch)
tree2f57d117f2bd934eac2768be18dcc866619f390f /src/H5.c
parentf16361d5f1dc70c344d8143270aa4aeaa867f244 (diff)
downloadhdf5-102337449220dfc29be1cce29147704b9c760832.zip
hdf5-102337449220dfc29be1cce29147704b9c760832.tar.gz
hdf5-102337449220dfc29be1cce29147704b9c760832.tar.bz2
[svn-r27768] Description:
Complete revamp of package initialization/shutdown mechanism in the library. Each package now has a single init/term routine. This new way should avoid packages being re-initialized during library shutdown and is also be _much_ more proactive about giving feedback for resource leaks internal to the library. Introduces a new "module" header file for packages in the library (e.g src/H5Fmodule.h) which sets up some necessary package configuration macros for the FUNC_ENTER/LEAVE macros. (The VFL drivers have their own slightly modified version of this header, src/H5FDdrvr_module.h) Also cleaned up a bunch of resources leaks all across the library and tests, along with addressing many warnings, as I encountered them. Tested on: MacOSX/64 10.10.5 (amazon) w/serial & parallel Linux/64 3.10.x (kituo) w/serial & parallel Linux/64 2.6.x (ostrich) w/serial
Diffstat (limited to 'src/H5.c')
-rw-r--r--src/H5.c51
1 files changed, 43 insertions, 8 deletions
diff --git a/src/H5.c b/src/H5.c
index 2e05819..29098bc 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -74,6 +74,7 @@ hbool_t H5_api_entered_g = FALSE;
H5_api_t H5_g;
#else
hbool_t H5_libinit_g = FALSE; /* Library hasn't been initialized */
+hbool_t H5_libterm_g = FALSE; /* Library isn't being shutdown */
#endif
#ifdef H5_HAVE_MPE
@@ -261,6 +262,9 @@ H5_term_library(void)
if(!(H5_INIT_GLOBAL))
goto done;
+ /* Indicate that the library is being shut down */
+ H5_TERM_GLOBAL = TRUE;
+
/* Check if we should display error output */
(void)H5Eget_auto2(H5E_DEFAULT, &func, NULL);
@@ -270,7 +274,7 @@ H5_term_library(void)
* way that would necessitate some cleanup work in the other interface.
*/
#define DOWN(F) \
- (((n = H5##F##_term_interface()) && (at + 8) < sizeof loop)? \
+ (((n = H5##F##_term_package()) && (at + 8) < sizeof loop)? \
(sprintf(loop + at, "%s%s", (at ? "," : ""), #F), \
at += HDstrlen(loop + at), \
n): \
@@ -281,20 +285,46 @@ H5_term_library(void)
do {
pending = 0;
+
/* Try to organize these so the "higher" level components get shut
* down before "lower" level components that they might rely on. -QAK
*/
- pending += DOWN(R);
- pending += DOWN(D);
pending += DOWN(L);
- pending += DOWN(G);
- pending += DOWN(A);
- pending += DOWN(S);
- pending += DOWN(T);
+
+ /* Close the "top" of various interfaces (IDs, etc) but don't shut
+ * down the whole interface yet, so that the object header messages
+ * get serialized correctly for entries in the metadata cache and the
+ * symbol table entry in the superblock gets serialized correctly, etc.
+ * all of which is performed in the 'F' shutdown.
+ */
+ pending += DOWN(A_top);
+ pending += DOWN(D_top);
+ pending += DOWN(G_top);
+ pending += DOWN(R_top);
+ pending += DOWN(S_top);
+ pending += DOWN(T_top);
+
/* Don't shut down the file code until objects in files are shut down */
if(pending == 0)
pending += DOWN(F);
+ /* Wait to shut down the "bottom" of various interfaces until the
+ * files are closed, so pieces of the file can be serialized
+ * correctly.
+ */
+ if(pending == 0) {
+ /* Shut down the "bottom" of the attribute, dataset, group,
+ * reference, dataspace, and datatype interfaces, fully closing
+ * out the interfaces now.
+ */
+ pending += DOWN(A);
+ pending += DOWN(D);
+ pending += DOWN(G);
+ pending += DOWN(R);
+ pending += DOWN(S);
+ pending += DOWN(T);
+ } /* end if */
+
/* Don't shut down "low-level" components until "high-level" components
* have successfully shut down. This prevents property lists and IDs
* from being closed "out from underneath" of the high-level objects
@@ -318,7 +348,7 @@ H5_term_library(void)
/* Don't shut down the free list code until _everything_ else is down */
if(pending == 0)
pending += DOWN(FL);
- }
+ } /* end if */
} while(pending && ntries++ < 100);
if(pending) {
@@ -362,12 +392,17 @@ H5_term_library(void)
(void)H5MM_free(tmp_open_stream);
} /* end while */
+ /* Reset flag indicating that the library is being shut down */
+ H5_TERM_GLOBAL = FALSE;
+
/* Mark library as closed */
H5_INIT_GLOBAL = FALSE;
+
done:
#ifdef H5_HAVE_THREADSAFE
H5_API_UNLOCK
#endif /* H5_HAVE_THREADSAFE */
+
return;
} /* end H5_term_library() */