From 7f5a5020c8ec882e6b7eceab878470003e2a8b63 Mon Sep 17 00:00:00 2001 From: Jerome Soumagne Date: Wed, 14 Aug 2019 14:41:14 -0500 Subject: Fix H5F_get_file_id and H5F__get_file_id to take app_ref parameter Fix app_ref_count from being incremented when private routines are used --- src/H5Fint.c | 10 +++++----- src/H5Fpkg.h | 2 +- src/H5Fprivate.h | 2 +- src/H5I.c | 2 +- src/H5VLnative_file.c | 3 ++- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/H5Fint.c b/src/H5Fint.c index c9c6658..8d08965 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -3647,7 +3647,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5F__get_file_id(H5F_t *file) +H5F__get_file_id(H5F_t *file, hbool_t app_ref) { hid_t file_id = H5I_INVALID_HID; /* File ID */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -3660,13 +3660,13 @@ H5F__get_file_id(H5F_t *file) /* If the ID does not exist, register it with the VOL connector */ if(H5I_INVALID_HID == file_id) { - if((file_id = H5VL_wrap_register(H5I_FILE, file, TRUE)) < 0) + if((file_id = H5VL_wrap_register(H5I_FILE, file, app_ref)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") file->id_exists = TRUE; } /* end if */ else { /* Increment ref count on existing ID */ - if(H5I_inc_ref(file_id, TRUE) < 0) + if(H5I_inc_ref(file_id, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") } /* end else */ @@ -3690,7 +3690,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5F_get_file_id(hid_t obj_id, H5I_type_t type) +H5F_get_file_id(hid_t obj_id, H5I_type_t type, hbool_t app_ref) { H5VL_object_t *vol_obj; /* File info */ hid_t file_id = H5I_INVALID_HID; /* File ID for object */ @@ -3703,7 +3703,7 @@ H5F_get_file_id(hid_t obj_id, H5I_type_t type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid identifier") /* Get the file through the VOL */ - if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FILE_ID, (int)type, &file_id) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FILE_ID, (int)type, (int)app_ref, &file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get file ID") if(H5I_INVALID_HID == file_id) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the file ID through the VOL") diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 1dd07c1..dbf68c3 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -408,7 +408,7 @@ H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); H5_DLL herr_t H5F__close(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); H5_DLL H5F_t *H5F__get_file(void *obj, H5I_type_t type); -H5_DLL hid_t H5F__get_file_id(H5F_t *file); +H5_DLL hid_t H5F__get_file_id(H5F_t *file, hbool_t app_ref); /* File mount related routines */ H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index a8ac158..838fa28 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -718,7 +718,7 @@ typedef enum H5F_prefix_open_t { /* Private functions */ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); -H5_DLL hid_t H5F_get_file_id(hid_t obj_id, H5I_type_t id_type); +H5_DLL hid_t H5F_get_file_id(hid_t obj_id, H5I_type_t id_type, hbool_t app_ref); /* Functions that retrieve values from the file struct */ H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f); diff --git a/src/H5I.c b/src/H5I.c index a2275de..ab68e38 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -2219,7 +2219,7 @@ H5Iget_file_id(hid_t obj_id) /* Call internal function */ if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - if ((ret_value = H5F_get_file_id(obj_id, type)) < 0) + if ((ret_value = H5F_get_file_id(obj_id, type, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") } /* end if */ else diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index eeaade6..0ac70e3 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -562,11 +562,12 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR case H5VL_NATIVE_FILE_GET_FILE_ID: { H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + hbool_t app_ref = (hbool_t)HDva_arg(arguments, int); hid_t *file_id = HDva_arg(arguments, hid_t *); if(NULL == (f = H5F__get_file(obj, type))) HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file or file object") - if((*file_id = H5F__get_file_id(f)) < 0) + if((*file_id = H5F__get_file_id(f, app_ref)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file ID") break; } -- cgit v0.12