diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2016-11-29 00:34:36 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2016-11-29 00:34:36 (GMT) |
commit | b092dbcdfdfc7477596ae49f816f18e0dadf0fb1 (patch) | |
tree | b2ddd93f609d6449936475e41529ad021038b217 /src/H5FDsec2.c | |
parent | a6ab26c74b29fff10e6a40bb351eb4a6eaa24162 (diff) | |
download | hdf5-b092dbcdfdfc7477596ae49f816f18e0dadf0fb1.zip hdf5-b092dbcdfdfc7477596ae49f816f18e0dadf0fb1.tar.gz hdf5-b092dbcdfdfc7477596ae49f816f18e0dadf0fb1.tar.bz2 |
Bring over another batch (hopefully the last) of non-SWMR "normalization"
changes from the revise_chunks branch.
Diffstat (limited to 'src/H5FDsec2.c')
-rw-r--r-- | src/H5FDsec2.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index bb8f004..04a0790 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -922,20 +922,24 @@ done: static herr_t H5FD_sec2_lock(H5FD_t *_file, hbool_t rw) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - int lock; /* The type of lock */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + int lock_flags; /* file locking flags */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - /* Determine the type of lock */ - lock = rw ? LOCK_EX : LOCK_SH; - - /* Place the lock with non-blocking */ - if(HDflock(file->fd, lock | LOCK_NB) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock file") + /* Set exclusive or shared lock based on rw status */ + lock_flags = rw ? LOCK_EX : LOCK_SH; + + /* Place a non-blocking lock on the file */ + if(HDflock(file->fd, lock_flags | LOCK_NB) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to lock file") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -956,15 +960,19 @@ done: static herr_t H5FD_sec2_unlock(H5FD_t *_file) { - H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ - herr_t ret_value = SUCCEED; /* Return value */ + H5FD_sec2_t *file = (H5FD_sec2_t *)_file; /* VFD file struct */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if(HDflock(file->fd, LOCK_UN) < 0) - HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to flock (unlock) file") + if(HDflock(file->fd, LOCK_UN) < 0) { + if(ENOSYS == errno) + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "file locking disabled on this file system (use HDF5_USE_FILE_LOCKING environment variable to override)") + else + HSYS_GOTO_ERROR(H5E_FILE, H5E_BADFILE, FAIL, "unable to unlock file") + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) |