summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2016-07-04 23:21:06 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2016-07-04 23:21:06 (GMT)
commitdfe0d7984a32dcef677eb8d70a355f093512624c (patch)
tree8fc14ff9560f76d06903c6de1e9ac02fb5c123cd /src
parent2889ea742e5c78b629ac69f6e8f9046843487d13 (diff)
downloadhdf5-dfe0d7984a32dcef677eb8d70a355f093512624c.zip
hdf5-dfe0d7984a32dcef677eb8d70a355f093512624c.tar.gz
hdf5-dfe0d7984a32dcef677eb8d70a355f093512624c.tar.bz2
[svn-r30145] Merge of checkin #30143 to the trunk which is a bug fix for HDFFV-9940.
Tested on oxs1010test, moohan, platypus, emu, kite, kituo, mayll, ostrich, quail.
Diffstat (limited to 'src')
-rw-r--r--src/H5Aint.c5
-rw-r--r--src/H5Dint.c5
-rw-r--r--src/H5T.c43
-rw-r--r--src/H5Tprivate.h1
4 files changed, 54 insertions, 0 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 81fa8b0..1a14bf5 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -202,6 +202,11 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
if(NULL == (attr->shared->dt = H5T_copy(type, H5T_COPY_ALL)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared datatype info")
+ /* Convert a datatype (if committed) to a transient type if the committed datatype's file
+ location is different from the file location where the attribute will be created */
+ if(H5T_convert_committed_datatype(attr->shared->dt, loc->oloc->file) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared datatype info")
+
/* Mark datatype as being on disk now */
if(H5T_set_loc(attr->shared->dt, loc->oloc->file, H5T_LOC_DISK) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 3d20e53..16ced02 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -638,6 +638,11 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type)
if((dset->shared->type = H5T_copy(type, H5T_COPY_ALL)) == NULL)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy datatype")
+ /* Convert a datatype (if committed) to a transient type if the committed datatype's file
+ location is different from the file location where the dataset will be created */
+ if(H5T_convert_committed_datatype(dset->shared->type, file) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get shared datatype info")
+
/* Mark any datatypes as being on disk now */
if(H5T_set_loc(dset->shared->type, file, H5T_LOC_DISK) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't set datatype location")
diff --git a/src/H5T.c b/src/H5T.c
index 9673ee9..2083e2d 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -4989,6 +4989,49 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
+/*-------------------------------------------------------------------------
+ * Function: H5T_convert_committed_datatype
+ *
+ * Purpose: To convert the committed datatype "dt" to a transient embedded
+ * type if the file location associated with the committed datatype is
+ * different from the parameter "f".
+ * "f" is the file location where the dataset or attribute will be created.
+ *
+ * Notes: See HDFFV-9940
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Vailin Choi; June 2016
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ HDassert(dt);
+ HDassert(f);
+
+ if(H5T_is_named(dt) && (dt->sh_loc.file != f)) {
+ HDassert(dt->sh_loc.type == H5O_SHARE_TYPE_COMMITTED);
+
+ H5O_msg_reset_share(H5O_DTYPE_ID, dt);
+ if(H5O_loc_free(&dt->oloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRESET, FAIL, "unable to initialize location")
+ if(H5G_name_free(&dt->path) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path")
+
+ dt->shared->state = H5T_STATE_TRANSIENT;
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_convert_committed_datatype() */
+
/*--------------------------------------------------------------------------
NAME
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 345924c..656036f 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -119,6 +119,7 @@ H5_DLL struct H5O_loc_t *H5T_oloc(H5T_t *dt);
H5_DLL H5G_name_t *H5T_nameof(H5T_t *dt);
H5_DLL htri_t H5T_is_immutable(const H5T_t *dt);
H5_DLL htri_t H5T_is_named(const H5T_t *dt);
+H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f);
H5_DLL htri_t H5T_is_relocatable(const H5T_t *dt);
H5_DLL H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst,
const char *name, H5T_conv_t func, hid_t dxpl_id, hbool_t is_api);