summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-03-22 16:32:40 (GMT)
committerGitHub <noreply@github.com>2021-03-22 16:32:40 (GMT)
commit60e14b826a22452934f7057196c1ce4d0054d97a (patch)
treecb33f8b4d8840a7d0e2c653bde8e73020837624d /test
parent05bc1905cb37d145c29c036bacb1caac63c7f0c9 (diff)
downloadhdf5-60e14b826a22452934f7057196c1ce4d0054d97a.zip
hdf5-60e14b826a22452934f7057196c1ce4d0054d97a.tar.gz
hdf5-60e14b826a22452934f7057196c1ce4d0054d97a.tar.bz2
File locks now work on Windows (#480)
* File locks now work on Windows Uses LockFileEx() and UnlockFileEx(). Fixes HDFFV-10191 (partial). * Committing clang-format changes * Committing clang-format changes * Fixes commenting in h5repack * Reworks H5Fis_accessible() H5Fis_accessible() created a new file handle and attempted to read through it, which will fail when a file has been opened with an exclusive lock on operating systems that have mandatory locks. This change uses the same scheme we use in H5Fopen() to check if the file is already open and only tries to read the file signature if the file has not already been opened. Also adds a test for this behavior. * Committing clang-format changes * Trivial change to force github to run actions Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r--test/tfile.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/tfile.c b/test/tfile.c
index c8c123c..0d2926f 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -1666,6 +1666,29 @@ test_file_is_accessible(const char *env_h5_drvr)
is_hdf5 = H5Fis_accessible(filename, fapl_id);
VERIFY(is_hdf5, TRUE, "H5Fis_accessible");
+ /*****************************************/
+ /* Newly created file that is still open */
+ /*****************************************/
+
+ /* On Windows, file locking is mandatory so this check ensures that
+ * H5Fis_accessible() works on files that have an exclusive lock.
+ * Previous versions of this API call created an additional file handle
+ * and attempted to read through it, which will not work when locks
+ * are enforced by the OS.
+ */
+
+ /* Create a file and hold it open */
+ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id);
+ CHECK(fid, H5I_INVALID_HID, "H5Fcreate");
+
+ /* Verify that the file is an HDF5 file */
+ is_hdf5 = H5Fis_accessible(filename, fapl_id);
+ VERIFY(is_hdf5, TRUE, "H5Fis_accessible");
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
/*******************************/
/* Non-default user block size */
/*******************************/