summaryrefslogtreecommitdiffstats
path: root/src/H5Doh.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2012-04-05 19:14:38 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2012-04-05 19:14:38 (GMT)
commitdee21e9e82cecc5a15d62e3fec02f3c46eb8231b (patch)
treed3eb67916366552f1dca12afa687951608c1bc68 /src/H5Doh.c
parent9ac4faa9230bb97c4e3f7c4465c6a55dbde30e14 (diff)
downloadhdf5-dee21e9e82cecc5a15d62e3fec02f3c46eb8231b.zip
hdf5-dee21e9e82cecc5a15d62e3fec02f3c46eb8231b.tar.gz
hdf5-dee21e9e82cecc5a15d62e3fec02f3c46eb8231b.tar.bz2
[svn-r22252] Fixed a bug in H5Ocopy(): When copying an opened object, call the object's
flush class action to ensure that cached data is flushed so that H5Ocopy will get the correct data. (HDFFV-7853) this line, and those below, will be ignored-- _M . M test/objcopy.c M src/H5Ocopy.c M src/H5Goh.c M src/H5Dint.c M src/H5Opkg.h M src/H5Doh.c M src/H5Toh.c M src/H5O.c M src/H5Dpkg.h M release_docs/RELEASE.txt _M fortran
Diffstat (limited to 'src/H5Doh.c')
-rw-r--r--src/H5Doh.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/H5Doh.c b/src/H5Doh.c
index 6496729..70884e8 100644
--- a/src/H5Doh.c
+++ b/src/H5Doh.c
@@ -56,6 +56,8 @@ static H5O_loc_t *H5O_dset_get_oloc(hid_t obj_id);
static herr_t H5O_dset_bh_info(H5F_t *f, hid_t dxpl_id, H5O_t *oh,
H5_ih_info_t *bh_info);
+static herr_t H5O_dset_flush(H5G_loc_t *obj_loc, hid_t dxpl_id);
+
/*********************/
/* Package Variables */
@@ -81,7 +83,8 @@ const H5O_obj_class_t H5O_OBJ_DATASET[1] = {{
H5O_dset_open, /* open an object of this class */
H5O_dset_create, /* create an object of this class */
H5O_dset_get_oloc, /* get an object header location for an object */
- H5O_dset_bh_info /* get the index & heap info for an object */
+ H5O_dset_bh_info, /* get the index & heap info for an object */
+ H5O_dset_flush /* flush an opened object of this class */
}};
/* Declare a free list to manage the H5D_copy_file_ud_t struct */
@@ -435,3 +438,48 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_dset_bh_info() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_dset_flush
+ *
+ * Purpose: To flush any dataset information cached in memory
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Vailin Choi
+ * February 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O_dset_flush(H5G_loc_t *obj_loc, hid_t dxpl_id)
+{
+ H5D_t *dset; /* Dataset opened */
+ H5O_type_t obj_type; /* Type of object at location */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(obj_loc);
+ HDassert(obj_loc->oloc);
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(obj_loc->oloc, &obj_type, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type")
+
+ if(obj_type != H5O_TYPE_DATASET)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset")
+
+ /* Open the dataset */
+ if(NULL == (dset = H5D_open(obj_loc, H5P_DATASET_ACCESS_DEFAULT, dxpl_id)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset")
+
+ if(H5D_flush_real(dset, dxpl_id) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info")
+
+done:
+ if(dset && H5D_close(dset) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset")
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_dset_flush() */