summaryrefslogtreecommitdiffstats
path: root/src/H5FDfamily.c
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2015-12-21 18:55:54 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2015-12-21 18:55:54 (GMT)
commitea0f5d813bb26ec536f468d47f79bf93fb5a9401 (patch)
tree9d1f2cec912ce29b877327ada906721b98d5f0c5 /src/H5FDfamily.c
parent26b328aec8e10b9101c76bc049b6b5045b5f00a5 (diff)
parent9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60 (diff)
downloadhdf5-ea0f5d813bb26ec536f468d47f79bf93fb5a9401.zip
hdf5-ea0f5d813bb26ec536f468d47f79bf93fb5a9401.tar.gz
hdf5-ea0f5d813bb26ec536f468d47f79bf93fb5a9401.tar.bz2
[svn-r28715] - merge from trunk
- fix farray, earray, and btree test to use correct function to retrieve internal file struct.
Diffstat (limited to 'src/H5FDfamily.c')
-rw-r--r--src/H5FDfamily.c83
1 files changed, 80 insertions, 3 deletions
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 9657f98..8655f17 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -106,6 +106,8 @@ static herr_t H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, h
size_t size, const void *_buf);
static herr_t H5FD_family_flush(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
static herr_t H5FD_family_truncate(H5FD_t *_file, hid_t dxpl_id, unsigned closing);
+static herr_t H5FD_family_lock(H5FD_t *_file, hbool_t rw);
+static herr_t H5FD_family_unlock(H5FD_t *_file);
/* The class struct */
static const H5FD_class_t H5FD_family_g = {
@@ -138,8 +140,8 @@ static const H5FD_class_t H5FD_family_g = {
H5FD_family_write, /*write */
H5FD_family_flush, /*flush */
H5FD_family_truncate, /*truncate */
- NULL, /*lock */
- NULL, /*unlock */
+ H5FD_family_lock, /*lock */
+ H5FD_family_unlock, /*unlock */
H5FD_FLMAP_DICHOTOMY /*fl_map */
};
@@ -853,7 +855,6 @@ H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
*
*-------------------------------------------------------------------------
*/
-/* ARGSUSED */
static herr_t
H5FD_family_query(const H5FD_t * _file, unsigned long *flags /* out */)
{
@@ -1296,3 +1297,79 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_family_truncate() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_family_lock
+ *
+ * Purpose: To place an advisory lock on a file.
+ * The lock type to apply depends on the parameter "rw":
+ * TRUE--opens for write: an exclusive lock
+ * FALSE--opens for read: a shared lock
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_family_lock(H5FD_t *_file, hbool_t rw)
+{
+ H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */
+ unsigned u, i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Place the lock on all the member files */
+ for(u = 0; u < file->nmembs; u++) {
+ if(file->memb[u]) {
+ if(H5FD_lock(file->memb[u], rw) < 0)
+ break;
+ } /* end if */
+ } /* end for */
+
+ if(u < file->nmembs) { /* Try to unlock the member files done before */
+ for(i = 0; i < u; i++) {
+ if(H5FD_unlock(file->memb[i]) < 0)
+ /* Push error, but keep going*/
+ HDONE_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
+ }
+ HGOTO_ERROR(H5E_IO, H5E_CANTLOCK, FAIL, "unable to lock member files")
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_family_lock() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FD_family_unlock
+ *
+ * Purpose: To remove the existing lock on the file
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; May 2013
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5FD_family_unlock(H5FD_t *_file)
+{
+ H5FD_family_t *file = (H5FD_family_t *)_file; /* VFD file struct */
+ unsigned u; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Remove the lock on the member files */
+ for(u = 0; u < file->nmembs; u++) {
+ if(file->memb[u]) {
+ if(H5FD_unlock(file->memb[u]) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
+ } /* end if */
+ } /* end for */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5FD_family_unlock() */