diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2015-09-14 20:22:39 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2015-09-14 20:22:39 (GMT) |
commit | 81e4ce7805a034e7684f48a208621180cc168921 (patch) | |
tree | c6f3187d6a49a314674d642eabda0554386c90b9 /src/H5.c | |
parent | c3649ea51764b1e7d2b82ca3d5a2ba4053f34a6d (diff) | |
parent | b2f94f9faf805035e4d0e9cb76007204c8250e58 (diff) | |
download | hdf5-81e4ce7805a034e7684f48a208621180cc168921.zip hdf5-81e4ce7805a034e7684f48a208621180cc168921.tar.gz hdf5-81e4ce7805a034e7684f48a208621180cc168921.tar.bz2 |
[svn-r27777] merge from trunk.
Diffstat (limited to 'src/H5.c')
-rw-r--r-- | src/H5.c | 97 |
1 files changed, 81 insertions, 16 deletions
@@ -21,16 +21,16 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Lprivate.h" /* Links */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5Pprivate.h" /* Property lists */ #include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -75,6 +75,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 @@ -265,6 +266,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); @@ -274,7 +278,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): \ @@ -285,20 +289,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 @@ -323,7 +353,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) { @@ -367,12 +397,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() */ @@ -977,6 +1012,36 @@ H5free_memory(void *mem) } /* end H5free_memory() */ +/*------------------------------------------------------------------------- + * Function: H5is_library_threadsafe + * + * Purpose: Checks to see if the library was built with thread-safety + * enabled. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5is_library_threadsafe(hbool_t *is_ts) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API_NOINIT + H5TRACE1("e", "*b", is_ts); + + HDassert(is_ts); + +#ifdef H5_HAVE_THREADSAFE + *is_ts = TRUE; +#else /* H5_HAVE_THREADSAFE */ + *is_ts = FALSE; +#endif /* H5_HAVE_THREADSAFE */ + + FUNC_LEAVE_API(ret_value) +} /* end H5is_library_threadsafe() */ + + #if defined(H5_HAVE_THREADSAFE) && defined(H5_BUILT_AS_DYNAMIC_LIB) \ && defined(H5_HAVE_WIN32_API) && defined(H5_HAVE_WIN_THREADS) /*------------------------------------------------------------------------- |