summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2019-09-12 19:16:49 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2019-09-12 19:16:49 (GMT)
commit1f4dd5692d16a9638e8be3d208eb05ccaedd3c62 (patch)
treeb38a67a5ce8c21bcd3232e9fc12c31301f2f3b89
parent0a81436fab1692ed394f83b6d595ad9a32cbc285 (diff)
downloadhdf5-1f4dd5692d16a9638e8be3d208eb05ccaedd3c62.zip
hdf5-1f4dd5692d16a9638e8be3d208eb05ccaedd3c62.tar.gz
hdf5-1f4dd5692d16a9638e8be3d208eb05ccaedd3c62.tar.bz2
Use h5_retry_init/_next to retry loading the SWMR shadow file.
-rw-r--r--src/H5FDvfd_swmr.c19
-rw-r--r--src/H5Fpublic.h1
-rw-r--r--src/H5Pfapl.c5
3 files changed, 15 insertions, 10 deletions
diff --git a/src/H5FDvfd_swmr.c b/src/H5FDvfd_swmr.c
index eb659e1..8765876 100644
--- a/src/H5FDvfd_swmr.c
+++ b/src/H5FDvfd_swmr.c
@@ -258,10 +258,8 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id,
H5P_genplist_t *plist; /* Property list pointer */
H5F_vfd_swmr_config_t *vfd_swmr_config = /* Points to VFD SWMR */
NULL; /* configuration */
- unsigned file_retries = /* Maximum retries for opening */
- H5FD_VFD_SWMR_MD_FILE_RETRY_MAX; /* md file */
- uint64_t nanosec = 1; /* # of nanoseconds to sleep */
- /* between retries */
+ h5_retry_t retry; /* retry state */
+ bool do_try; /* more tries remain */
H5FD_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -306,16 +304,17 @@ H5FD_vfd_swmr_open(const char *name, unsigned flags, hid_t fapl_id,
file->md_file_path[sizeof(file->md_file_path) - 1] = '\0';
/* Retry on opening the metadata file */
- do {
+ for (do_try = h5_retry_init(&retry, vfd_swmr_config->md_open_tries,
+ H5_RETRY_DEFAULT_MINIVAL,
+ H5_RETRY_DEFAULT_MAXIVAL);
+ do_try != 0;
+ do_try = h5_retry_next(&retry)) {
if((file->md_fd = HDopen(file->md_file_path, O_RDONLY)) >= 0)
break;
- /* Sleep and double the sleep time on next retry */
- H5_nanosleep(nanosec);
- nanosec *= 2;
- } while (--file_retries);
+ }
/* Exhaust all retries for opening the md file */
- if(file_retries == 0)
+ if(!do_try)
HGOTO_ERROR(H5E_VFL, H5E_OPENERROR, NULL, \
"unable to open the metadata file after all retry attempts")
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index c2bfb21..9bf3658 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -229,6 +229,7 @@ typedef struct H5F_vfd_swmr_config_t {
int32_t md_pages_reserved;
char md_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1];
char log_file_path[H5F__MAX_VFD_SWMR_FILE_NAME_LEN + 1];
+ unsigned md_open_tries;
} H5F_vfd_swmr_config_t;
#ifdef __cplusplus
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 71ab475..1f1f67b 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -5113,6 +5113,11 @@ H5Pset_vfd_swmr_config(hid_t plist_id, H5F_vfd_swmr_config_t *config_ptr)
else if(name_len > H5F__MAX_VFD_SWMR_FILE_NAME_LEN)
HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_file_path is too long")
+ if (config_ptr->md_open_tries == 0)
+ config_ptr->md_open_tries = H5FD_VFD_SWMR_MD_FILE_RETRY_MAX;
+ else if (config_ptr->md_open_tries > H5FD_VFD_SWMR_MD_FILE_RETRY_MAX)
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "md_open_tries is too long")
+
/* Set the modified config */
if(H5P_set(plist, H5F_ACS_VFD_SWMR_CONFIG_NAME, config_ptr) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache initial config")