diff options
author | jhendersonHDF <jhenderson@hdfgroup.org> | 2024-03-01 13:38:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 13:38:17 (GMT) |
commit | cc50a78000a7dc536ecff0f62b7206708987bc7d (patch) | |
tree | ac4397e3f903b5ff8ce99517b9eda2123eef7207 /test/h5test.c | |
parent | 662ee679e0198efc984c778b86db470366706e2a (diff) | |
download | hdf5-cc50a78000a7dc536ecff0f62b7206708987bc7d.zip hdf5-cc50a78000a7dc536ecff0f62b7206708987bc7d.tar.gz hdf5-cc50a78000a7dc536ecff0f62b7206708987bc7d.tar.bz2 |
Fix issue with FAPL file locking setting inheriting test (#4053)
Fixes an issue where the HDF5_USE_FILE_LOCKING environment variable being
set can interfere with the file locking setting that the test expects to
be returned.
Diffstat (limited to 'test/h5test.c')
-rw-r--r-- | test/h5test.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/h5test.c b/test/h5test.c index 77a65c2..1cca57a 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -2068,6 +2068,49 @@ error: } /* end h5_check_if_file_locking_enabled() */ /*------------------------------------------------------------------------- + * Function: h5_check_file_locking_env_var + * + * Purpose: Checks if the HDF5_USE_FILE_LOCKING file locking + * environment variable is set and parses its value if so. + * + * If the environment variable is not set, both `use_locks` + * and `ignore_disabled_locks` will be set to FAIL to indicate + * this. Otherwise, they will each be set appropriately based + * on the setting for the environment variable. + * + * Return: Nothing + * + *------------------------------------------------------------------------- + */ +void +h5_check_file_locking_env_var(htri_t *use_locks, htri_t *ignore_disabled_locks) +{ + char *lock_env_var = NULL; + + assert(use_locks); + assert(ignore_disabled_locks); + + lock_env_var = getenv(HDF5_USE_FILE_LOCKING); + if (lock_env_var && (!strcmp(lock_env_var, "FALSE") || !strcmp(lock_env_var, "0"))) { + *use_locks = false; /* Override: Never use locks */ + *ignore_disabled_locks = FAIL; + } + else if (lock_env_var && !strcmp(lock_env_var, "BEST_EFFORT")) { + *use_locks = true; /* Override: Always use locks */ + *ignore_disabled_locks = true; /* Override: Ignore disabled locks */ + } + else if (lock_env_var && (!strcmp(lock_env_var, "TRUE") || !strcmp(lock_env_var, "1"))) { + *use_locks = true; /* Override: Always use locks */ + *ignore_disabled_locks = false; /* Override: Don't ignore disabled locks */ + } + else { + /* Environment variable not set, or not set correctly */ + *use_locks = FAIL; + *ignore_disabled_locks = FAIL; + } +} + +/*------------------------------------------------------------------------- * Function: h5_using_native_vol * * Purpose: Checks if the VOL connector being used is (or the VOL |