summaryrefslogtreecommitdiffstats
path: root/src/H5Oflush.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2014-01-08 17:09:23 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2014-01-08 17:09:23 (GMT)
commita196a4f351abed0670c10bc50887bd4e56dd4775 (patch)
treecc56e2d57884eae938e6606624d0c619d6dfe541 /src/H5Oflush.c
parent955c0736022947649441634f7ee3dc5c973085d4 (diff)
downloadhdf5-a196a4f351abed0670c10bc50887bd4e56dd4775.zip
hdf5-a196a4f351abed0670c10bc50887bd4e56dd4775.tar.gz
hdf5-a196a4f351abed0670c10bc50887bd4e56dd4775.tar.bz2
[svn-r24622] Implementation (pending code review) for:
(A) SWMR related public routines: H5Fstart_swmr_write, H5Pget/set_append_flush, H5Pget/set_object_flush_cb. (B) File locking. Tested on jam, koala, ostrich, platypus.
Diffstat (limited to 'src/H5Oflush.c')
-rw-r--r--src/H5Oflush.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/src/H5Oflush.c b/src/H5Oflush.c
index 06448fe..489afb2 100644
--- a/src/H5Oflush.c
+++ b/src/H5Oflush.c
@@ -48,7 +48,7 @@
/*-------------------------------------------------------------------------
- * Function: H5Oflush
+ * Function: H5Oflush
*
* Purpose: Flushes all buffers associated with an object to disk.
*
@@ -63,6 +63,8 @@ herr_t
H5Oflush(hid_t obj_id)
{
H5O_loc_t *oloc; /* object location */
+ void *obj_ptr; /* Pointer to object */
+ const H5O_obj_class_t *obj_class = NULL; /* Class of object */
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_API(FAIL)
@@ -71,15 +73,57 @@ H5Oflush(hid_t obj_id)
/* Check args */
if((oloc = H5O_get_loc(obj_id)) == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an object")
-
- /* Private function */
- if (H5O_flush_metadata(oloc, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to flush object")
+
+ /* Get the object pointer */
+ if((obj_ptr = H5I_object(obj_id)) == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* Get the object class */
+ if((obj_class = H5O_obj_class(oloc, H5AC_dxpl_id)) == NULL)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to determine object class")
+
+ /* Flush the object of this class */
+ if(obj_class->flush && obj_class->flush(obj_ptr, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object")
+
+ /* Flush the object metadata and invoke flush callback */
+ if(H5O_flush_common(oloc, obj_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object and object flush callback")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Oflush */
+/*-------------------------------------------------------------------------
+ * Function: H5O_flush_common
+ *
+ * Purpose: Flushes the object's metadata
+ * Invokes the user-defined callback if there is one.
+ *
+ * Return: Non-negative on success, negative on failure
+ *
+ * Programmer: Vailin Choi; Dec 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Private function */
+ if(H5O_flush_metadata(oloc, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object metadata")
+
+ /* Check to invoke callback */
+ if(H5F_object_flush_cb(oloc->file, obj_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to do object flush callback")
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}
+
/*-------------------------------------------------------------------------
* Function: H5O_flush_metadata