From a83eecc97499ccae1305fdede99cfefae019422b Mon Sep 17 00:00:00 2001 From: mattjala <124107509+mattjala@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:25:11 -0600 Subject: [PATCH] Set connection info even with non-default FAPL (#81) h5py uses a dynamically loaded connector while providing a non-default FAPL, and still needs the connection info to be set. --- src/rest_vol.c | 7 ++++++- src/rest_vol_file.c | 22 ++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/rest_vol.c b/src/rest_vol.c index 4cc5ce46..7360ef54 100644 --- a/src/rest_vol.c +++ b/src/rest_vol.c @@ -39,7 +39,8 @@ */ hid_t H5_rest_id_g = H5I_UNINIT; -static hbool_t H5_rest_initialized_g = FALSE; +static hbool_t H5_rest_initialized_g = FALSE; +static hbool_t H5_rest_connection_info_initialized_g = FALSE; /* Identifiers for HDF5's error API */ hid_t H5_rest_err_stack_g = H5I_INVALID_HID; @@ -728,6 +729,9 @@ H5_rest_set_connection_information(void) FILE *config_file = NULL; herr_t ret_value = SUCCEED; + if (H5_rest_connection_info_initialized_g) + FUNC_GOTO_DONE(SUCCEED); + memset(&ad_info, 0, sizeof(ad_info)); /* @@ -960,6 +964,7 @@ H5_rest_set_connection_information(void) "must specify a base URL - please set HSDS_ENDPOINT environment variable or create a " "config file"); + H5_rest_connection_info_initialized_g = TRUE; done: if (config_file) fclose(config_file); diff --git a/src/rest_vol_file.c b/src/rest_vol_file.c index 9d290588..5ee4c474 100644 --- a/src/rest_vol_file.c +++ b/src/rest_vol_file.c @@ -70,15 +70,8 @@ RV_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, h printf(" - Default FAPL? %s\n\n", (H5P_FILE_ACCESS_DEFAULT == fapl_id) ? "yes" : "no"); #endif - /* - * If the connector has been dynamically loaded, the FAPL used for - * creating the file will be a default FAPL, so we need to ensure - * that the connection information gets set. - */ - if (fapl_id == H5P_FILE_ACCESS_DEFAULT) - if (H5_rest_set_connection_information() < 0) - FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, - "can't set REST VOL connector connection information"); + if (H5_rest_set_connection_information() < 0) + FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't set REST VOL connector connection information"); if (fapl_id == H5I_INVALID_HID) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid FAPL"); @@ -349,15 +342,8 @@ RV_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, voi printf(" - Default FAPL? %s\n\n", (H5P_FILE_ACCESS_DEFAULT == fapl_id) ? "yes" : "no"); #endif - /* - * If the connector has been dynamically loaded, the FAPL used for - * creating the file will be a default FAPL, so we need to ensure - * that the connection information gets set. - */ - if (fapl_id == H5P_FILE_ACCESS_DEFAULT) - if (H5_rest_set_connection_information() < 0) - FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, - "can't set REST VOL connector connection information"); + if (H5_rest_set_connection_information() < 0) + FUNC_GOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't set REST VOL connector connection information"); if (fapl_id == H5I_INVALID_HID) FUNC_GOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid FAPL");