diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2015-12-14 10:03:54 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2015-12-14 10:03:54 (GMT) |
commit | 7e4fb729137dff3851122be63beabfc03137be4a (patch) | |
tree | 490996cc619adf8cd059e2df66aba441d51bc09f /src/H5FD.c | |
parent | f6c7631b3c40e03abe228cf9b3c2308c610d04cd (diff) | |
download | hdf5-7e4fb729137dff3851122be63beabfc03137be4a.zip hdf5-7e4fb729137dff3851122be63beabfc03137be4a.tar.gz hdf5-7e4fb729137dff3851122be63beabfc03137be4a.tar.bz2 |
[svn-r28626] Brought VFD-level file locking code over from revise_chunks.
Tested on:
Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1
serial only
(these changes have been in revise_chunks for a long time)
Diffstat (limited to 'src/H5FD.c')
-rw-r--r-- | src/H5FD.c | 125 |
1 files changed, 125 insertions, 0 deletions
@@ -1733,6 +1733,131 @@ done: /*------------------------------------------------------------------------- + * Function: H5FDlock + * + * Purpose: Set a file lock + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi; March 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FDlock(H5FD_t *file, hbool_t rw) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "*xb", file, rw); + + /* Check args */ + if(!file || !file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + + /* The real work */ + if(H5FD_lock(file, rw) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file lock request failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5FDlock() */ + + + +/*------------------------------------------------------------------------- + * Function: H5FD_lock + * + * Purpose: Private version of H5FDlock() + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi; May 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FD_lock(H5FD_t *file, hbool_t rw) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file && file->cls); + + if(file->cls->lock && (file->cls->lock)(file, rw) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver lock request failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_lock() */ + + +/*------------------------------------------------------------------------- + * Function: H5FDunlock + * + * Purpose: Remove a file lock + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi; March 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FDunlock(H5FD_t *file) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "*x", file); + + /* Check args */ + if(!file || !file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + + /* The real work */ + if(H5FD_unlock(file) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file unlock request failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5FDunlock() */ + + +/*------------------------------------------------------------------------- + * Function: H5FD_unlock + * + * Purpose: Private version of H5FDunlock() + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Vailin Choi; May 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5FD_unlock(H5FD_t *file) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file && file->cls); + + if(file->cls->unlock && (file->cls->unlock)(file) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver unlock request failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5FD_unlock() */ + + +/*------------------------------------------------------------------------- * Function: H5FD_get_fileno * * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value |