summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2019-10-11 06:19:42 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2019-10-11 22:40:40 (GMT)
commit294e4faab724c26985867fe8ede684967da8a698 (patch)
treee7456e1777fd52f0280f0cea36795b03e4ec23d3 /src/H5O.c
parent1cac341502d8acb296f41db38d31b7eb8021ffdb (diff)
downloadhdf5-294e4faab724c26985867fe8ede684967da8a698.zip
hdf5-294e4faab724c26985867fe8ede684967da8a698.tar.gz
hdf5-294e4faab724c26985867fe8ede684967da8a698.tar.bz2
Fix encode and decode of tokens in H5VLnative
Fix encode and decode of deprecated object reference addresses Make H5Rdeprec.c use tokens instead of haddr_t Fix H5Oopen_by_addr() to serialize addr to token
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c44
1 files changed, 36 insertions, 8 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 0c999ba..ffb49d9 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -255,22 +255,48 @@ hid_t
H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
{
H5VL_object_t *vol_obj; /* Object token of loc_id */
- H5I_type_t opened_type;
- void *opened_obj = NULL;
- H5VL_loc_params_t loc_params;
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
+ H5I_type_t opened_type; /* Opened object type */
+ void *opened_obj = NULL; /* Opened object */
+ H5VL_loc_params_t loc_params; /* Location parameters */
+ H5VL_token_t obj_token = {0}; /* Object token */
+ hid_t file_id = H5I_INVALID_HID; /* File ID */
+ void *vol_obj_file = NULL; /* Object token of file_id */
+ H5F_t *f = NULL;
+ uint8_t *p = NULL;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "ia", loc_id, addr);
- loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = &addr;
- loc_params.obj_type = H5I_get_type(loc_id);
-
/* Get the location object */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+ /* Get object type */
+ if((vol_obj_type = H5I_get_type(loc_id)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+
+ /* Get the file for the object */
+ if((file_id = H5F_get_file_id(loc_id, vol_obj_type, FALSE)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file or file object")
+
+ /* Retrieve VOL object */
+ if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+
+ /* Retrieve file from VOL object */
+ if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object")
+
+ /* This is a native specific routine that requires serialization of the token */
+ p = obj_token;
+ H5F_addr_encode(f, &p, addr);
+
+ loc_params.type = H5VL_OBJECT_BY_TOKEN;
+ loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.obj_type = vol_obj_type;
+
/* Open the object */
if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object")
@@ -280,6 +306,8 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle")
done:
+ if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file")
FUNC_LEAVE_API(ret_value)
} /* end H5Oopen_by_addr() */