summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c4
-rw-r--r--src/H5D.c4
-rw-r--r--src/H5T.c36
-rw-r--r--src/H5Tprivate.h1
4 files changed, 45 insertions, 0 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 0abaa0a..29cfbe8 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -1268,6 +1268,10 @@ H5Aget_type(hid_t attr_id)
if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
+ /* Patch the datatype's "top level" file pointer */
+ if(H5T_patch_file(attr->shared->dt, attr->oloc.file) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to patch datatype's file pointer")
+
/*
* Copy the attribute's datatype. If the type is a named type then
* reopen the type before returning it to the user. Make the type
diff --git a/src/H5D.c b/src/H5D.c
index 667fe1fb..132e384 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -523,6 +523,10 @@ H5Dget_type(hid_t dset_id)
if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
+ /* Patch the datatype's "top level" file pointer */
+ if(H5T_patch_file(dset->shared->type, dset->oloc.file) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to patch datatype's file pointer")
+
/* Copy the dataset's datatype */
if(NULL == (dt = H5T_copy(dset->shared->type, H5T_COPY_REOPEN)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype")
diff --git a/src/H5T.c b/src/H5T.c
index 3f0f46b..ed54051 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -5301,3 +5301,39 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_set_latest_version() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_patch_file
+ *
+ * Purpose: Patch the top-level file pointers contained in dt to point
+ * to f, if dt is a committed type. This is possible because
+ * the top-level file pointer can be closed out from under
+ * dt while dt is contained in the shared file's cache.
+ *
+ * Return: SUCCEED
+ *
+ * Programmer: Neil Fortner
+ * Thursday, July 14, 2011
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_patch_file(H5T_t *dt, H5F_t *f)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5T_patch_file, FAIL)
+
+ /* Sanity check */
+ HDassert(dt);
+ HDassert(f);
+
+ if(H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state) {
+ dt->oloc.file = f;
+ dt->sh_loc.file = f;
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_patch_file() */
+
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index c70eea0..0c96896 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -135,6 +135,7 @@ H5_DLL htri_t H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc);
H5_DLL htri_t H5T_is_sensible(const H5T_t *dt);
H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt);
H5_DLL herr_t H5T_set_latest_version(H5T_t *dt);
+H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f);
H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt);
/* Reference specific functions */