summaryrefslogtreecommitdiffstats
path: root/src/H5Doh.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2012-03-28 06:21:14 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2012-03-28 06:21:14 (GMT)
commitb643da672a7d0f0a52ecfef2c229e73876e0e13d (patch)
treec7e1b198aabf41b0e947a1b5372ab147a718a5d9 /src/H5Doh.c
parent0ce5cbc925da284019918d36a72eb30e96d9789b (diff)
downloadhdf5-b643da672a7d0f0a52ecfef2c229e73876e0e13d.zip
hdf5-b643da672a7d0f0a52ecfef2c229e73876e0e13d.tar.gz
hdf5-b643da672a7d0f0a52ecfef2c229e73876e0e13d.tar.bz2
[svn-r22164] 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)
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 7a657ec..e6a715f 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 */
@@ -431,3 +434,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() */