summaryrefslogtreecommitdiffstats
path: root/src/H5Pint.c
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2021-09-29 18:28:12 (GMT)
committerGitHub <noreply@github.com>2021-09-29 18:28:12 (GMT)
commit3da0802c40d58759995916bf9d0880e19f0af44d (patch)
tree809ada78cec1cbaaf6ec2ace5b4429a56d0f6574 /src/H5Pint.c
parent0fa5836cc5f037dd9f2cdd7f9a1051ddcc1c9ad0 (diff)
downloadhdf5-3da0802c40d58759995916bf9d0880e19f0af44d.zip
hdf5-3da0802c40d58759995916bf9d0880e19f0af44d.tar.gz
hdf5-3da0802c40d58759995916bf9d0880e19f0af44d.tar.bz2
VFD plugins (#602)
* Implement support for loading of Virtual File Drivers as plugins Fix plugin caching for VOL connector and VFD plugins Fix plugin iteration to skip paths that can't be opened * Enable dynamic loading of VFDs with HDF5_DRIVER environment variable * Temporarily disable error reporting during H5F_open double file open * Default to using HDstat in h5_get_file_size for unknown VFDs * Use macros for some environment variables that HDF5 interprets * Update "null" and "ctl testing" VFDs
Diffstat (limited to 'src/H5Pint.c')
-rw-r--r--src/H5Pint.c74
1 files changed, 63 insertions, 11 deletions
diff --git a/src/H5Pint.c b/src/H5Pint.c
index 9530d87..9206d4c 100644
--- a/src/H5Pint.c
+++ b/src/H5Pint.c
@@ -412,20 +412,22 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{
}};
/*-------------------------------------------------------------------------
- * Function: H5P_init
+ * Function: H5P_init_phase1
*
- * Purpose: Initialize the interface from some other layer.
+ * Purpose: Initialize the interface from some other layer. This should
+ * be followed with a call to H5P_init_phase2 after the H5P
+ * interface is completely setup.
*
- * Return: Success: non-negative
- * Failure: negative
+ * Return: Success: non-negative
+ * Failure: negative
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
* Saturday, March 4, 2000
*
*-------------------------------------------------------------------------
*/
herr_t
-H5P_init(void)
+H5P_init_phase1(void)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -434,7 +436,36 @@ H5P_init(void)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5P_init() */
+} /* end H5P_init_phase1() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_init_phase2
+ *
+ * Purpose: Finish initializing the interface from some other package.
+ *
+ * Note: This is broken out as a separate routine so that the
+ * library's default VFL driver can be chosen and initialized
+ * after the entire H5P interface has been initialized.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5P_init_phase2(void)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Set up the default VFL driver */
+ if (H5P__facc_set_def_driver() < 0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTSET, FAIL, "unable to set default VFL driver")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_init_phase2() */
/*--------------------------------------------------------------------------
NAME
@@ -449,8 +480,9 @@ DESCRIPTION
herr_t
H5P__init_package(void)
{
- size_t tot_init; /* Total # of classes initialized */
- size_t pass_init; /* # of classes initialized in each pass */
+ size_t tot_init = 0; /* Total # of classes initialized */
+ size_t pass_init; /* # of classes initialized in each pass */
+ size_t u;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -472,8 +504,6 @@ H5P__init_package(void)
*/
tot_init = 0;
do {
- size_t u; /* Local index variable */
-
/* Reset pass initialization counter */
pass_init = 0;
@@ -523,6 +553,28 @@ H5P__init_package(void)
HDassert(tot_init == NELMTS(init_class));
done:
+ if (ret_value < 0 && tot_init > 0) {
+ /* First uninitialize all default property lists */
+ H5I_clear_type(H5I_GENPROP_LST, FALSE, FALSE);
+
+ /* Then uninitialize any initialized libclass */
+ for (u = 0; u < NELMTS(init_class); u++) {
+ H5P_libclass_t const *lib_class = init_class[u]; /* Current class to operate on */
+
+ HDassert(lib_class->class_id);
+ if (*lib_class->class_id >= 0) {
+ /* Close the class ID */
+ if (H5I_dec_ref(*lib_class->class_id) < 0)
+ HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class ID")
+ }
+ else if (lib_class->pclass && *lib_class->pclass) {
+ /* Close a half-initialized pclass */
+ if (H5P__close_class(*lib_class->pclass) < 0)
+ HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to close property list class")
+ }
+ }
+ }
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__init_package() */