summaryrefslogtreecommitdiffstats
path: root/src/H5FDfamily.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-11-29 20:06:37 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-11-29 20:06:37 (GMT)
commitd3dbe9d90ee71b231b3264e1d62d3efbae3242ef (patch)
treeb8d706ac89af0822c0ac5cf0e1ab78fa5c3b5b1e /src/H5FDfamily.c
parent8fd8115715a2890da432cf2708109a35ea1c33e5 (diff)
parent3d2beeec1fb63c8c2bac4658df382ea7a9d61e05 (diff)
downloadhdf5-d3dbe9d90ee71b231b3264e1d62d3efbae3242ef.zip
hdf5-d3dbe9d90ee71b231b3264e1d62d3efbae3242ef.tar.gz
hdf5-d3dbe9d90ee71b231b3264e1d62d3efbae3242ef.tar.bz2
Merge branch 'develop' into eoc_valgrind_bugfix
Diffstat (limited to 'src/H5FDfamily.c')
-rw-r--r--src/H5FDfamily.c47
1 files changed, 25 insertions, 22 deletions
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 7ec8751..f0d4dba 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -1339,33 +1339,37 @@ done:
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 */
+ 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
/* Place the lock on all the member files */
- for(u = 0; u < file->nmembs; u++) {
- if(file->memb[u]) {
+ for(u = 0; u < file->nmembs; u++)
+ if(file->memb[u])
if(H5FD_lock(file->memb[u], rw) < 0)
- break;
- } /* end if */
- } /* end for */
+ break;
- 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")
+ /* If one of the locks failed, try to unlock the locked member files
+ * in an attempt to return to a fully unlocked state.
+ */
+ if(u < file->nmembs) {
+ unsigned v; /* Local index variable */
+
+ for(v = 0; v < v; v++) {
+ if(H5FD_unlock(file->memb[v]) < 0)
+ /* Push error, but keep going */
+ HDONE_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
+ } /* end for */
+ 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
*
@@ -1381,19 +1385,18 @@ 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 */
+ 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]) {
+ 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 */
+ HGOTO_ERROR(H5E_IO, H5E_CANTUNLOCK, FAIL, "unable to unlock member files")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FD_family_unlock() */
+