summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-08-17 17:54:07 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-08-17 17:54:07 (GMT)
commit32a1188bbd648e981615a388a8ca011df76fa1e0 (patch)
tree7df1dee94f272b1334a0497fc8a1d63b2a601907 /src/H5Fint.c
parent5d8c5849e5a3fe2b6a1e7c7d218da301edcc8f09 (diff)
downloadhdf5-32a1188bbd648e981615a388a8ca011df76fa1e0.zip
hdf5-32a1188bbd648e981615a388a8ca011df76fa1e0.tar.gz
hdf5-32a1188bbd648e981615a388a8ca011df76fa1e0.tar.bz2
Adds fix for H5Fstart_swmr_write lock issue
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 46508fe..a29d20b 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -1872,6 +1872,9 @@ 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")
@@ -3571,6 +3574,7 @@ 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
@@ -3695,6 +3699,12 @@ H5F__start_swmr_write(H5F_t *f)
setup = TRUE;
+ /* Place an advisory lock on the file */
+ if(f->use_file_locking)
+ if(H5FD_lock(f->shared->lf, TRUE) < 0) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTLOCKFILE, FAIL, "unable to lock the file")
+ }
+
/* Mark superblock as dirty */
if(H5F_super_dirty(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTMARKDIRTY, FAIL, "unable to mark superblock as dirty")
@@ -3712,10 +3722,6 @@ H5F__start_swmr_write(H5F_t *f)
if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_connector, TRUE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object")
- /* Unlock the file */
- if(H5FD_unlock(f->shared->lf) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to unlock the file")
-
done:
if(ret_value < 0 && setup) {
@@ -3744,6 +3750,11 @@ done:
HDONE_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush superblock")
} /* end if */
+ /* Unlock the file */
+ if(f->use_file_locking)
+ if(H5FD_unlock(f->shared->lf) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTUNLOCKFILE, FAIL, "unable to unlock the file")
+
/* Free memory */
if(obj_ids)
H5MM_xfree(obj_ids);