summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-08-17 21:25:04 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-08-17 21:25:04 (GMT)
commitf02ced7e7443563581930a6c2d58d1628608bbdd (patch)
tree490bf669896e2b07c5a5094063f87ab2be2b0914 /src/H5Fint.c
parent32a1188bbd648e981615a388a8ca011df76fa1e0 (diff)
downloadhdf5-f02ced7e7443563581930a6c2d58d1628608bbdd.zip
hdf5-f02ced7e7443563581930a6c2d58d1628608bbdd.tar.gz
hdf5-f02ced7e7443563581930a6c2d58d1628608bbdd.tar.bz2
Moves lock flag to H5F_shared_t and adds test.
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index a29d20b..7e3876f 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -1872,9 +1872,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
set_flag = TRUE;
} /* end else */
- /* Set the file locking flag */
- file->use_file_locking = use_file_locking;
-
/* Check to see if both SWMR and cache image are requested. Fail if so */
if(H5C_cache_image_status(file, &ci_load, &ci_write) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get MDC cache image status")
@@ -1888,6 +1885,15 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
shared = file->shared;
lf = shared->lf;
+ /* Set the file locking flag. If the file is already open, the file
+ * requested file locking flag must match that of the open file.
+ */
+ if(shared->nrefs == 1)
+ file->shared->use_file_locking = use_file_locking;
+ else if(shared->nrefs > 1)
+ if(file->shared->use_file_locking != use_file_locking)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file locking flag values don't match")
+
/* Check if page buffering is enabled */
if(H5P_get(a_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &page_buf_size) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get page buffer size")
@@ -3574,7 +3580,6 @@ H5F__start_swmr_write(H5F_t *f)
size_t u; /* Local index variable */
hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */
H5VL_t *vol_connector = NULL; /* VOL connector for the file */
- hbool_t use_file_locking = TRUE;/* Using file locks? */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
@@ -3700,7 +3705,7 @@ H5F__start_swmr_write(H5F_t *f)
setup = TRUE;
/* Place an advisory lock on the file */
- if(f->use_file_locking)
+ if(H5F_USE_FILE_LOCKING(f))
if(H5FD_lock(f->shared->lf, TRUE) < 0) {
HGOTO_ERROR(H5E_FILE, H5E_CANTLOCKFILE, FAIL, "unable to lock the file")
}
@@ -3751,7 +3756,7 @@ done:
} /* end if */
/* Unlock the file */
- if(f->use_file_locking)
+ if(H5F_USE_FILE_LOCKING(f))
if(H5FD_unlock(f->shared->lf) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock the file")