From e3f35800977504c45ec2847f1f23b7f5ba48ad76 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 12 Jul 2012 11:27:42 -0500 Subject: [svn-r22565] change OH id registration to original way, and re-register the ID with the VOL info on the upper level (API and iteration/visit routines) - this fixes the bug exposed in H5Oopen with external log plugin update the private VL registration routine to take an app_ref update the datatype ID creation for the VOL to take an app_ref --- src/H5A.c | 13 +++++++++++++ src/H5Aint.c | 14 ++------------ src/H5Dint.c | 12 +----------- src/H5Doh.c | 2 +- src/H5Goh.c | 2 +- src/H5Lexternal.c | 14 ++++++++++++++ src/H5O.c | 55 +++++++++++++++++++++++++++++++++++-------------------- src/H5R.c | 8 ++------ src/H5Rdeprec.c | 2 +- src/H5Tcommit.c | 8 ++++---- src/H5Tdeprec.c | 2 +- src/H5Toh.c | 16 ++++------------ src/H5Tprivate.h | 2 +- src/H5VL.c | 45 ++++----------------------------------------- src/H5VLint.c | 17 ++++++----------- src/H5VLnative.c | 19 +++++++++++++++++-- src/H5VLprivate.h | 2 +- src/H5VLpublic.h | 2 +- 18 files changed, 109 insertions(+), 126 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index a4558fe..7ba7a6e 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -1508,6 +1508,19 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* get the native object from the ID created by the object header and create + a "VOL object" ID */ + { + void *temp_obj = NULL; + H5I_type_t obj_type; + obj_type = H5I_get_type(obj_loc_id); + if(NULL == (temp_obj = H5I_remove(obj_loc_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Get an atom for the datatype */ + if((obj_loc_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } + /* Build attribute operator info */ attr_op.op_type = H5A_ATTR_OP_APP2; attr_op.u.app_op2 = op; diff --git a/src/H5Aint.c b/src/H5Aint.c index 8d86931..431ea17 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -282,7 +282,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, ret_value = attr; done: if(NULL == ret_value && attr && H5A_close(attr)) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "can't close attribute") FUNC_LEAVE_NOAPI_TAG(ret_value, NULL) } /* H5A_create() */ @@ -748,7 +748,6 @@ hid_t H5A_get_type(H5A_t *attr) { H5T_t *dt = NULL; - H5T_t *type = NULL; hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT @@ -778,14 +777,7 @@ H5A_get_type(H5A_t *attr) /* If this is a committed datatype, we need to recreate the two level IDs, where the VOL object is a copy of the returned datatype */ - /* Copy the dataset's datatype */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") - - H5T_set_vol_object(type, (void *)dt); - - /* get an ID for the object */ - if((ret_value = H5VL_native_register(H5I_DATATYPE, type, TRUE)) < 0) + if((ret_value = H5VL_native_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") } else { @@ -797,8 +789,6 @@ done: if(ret_value < 0) { if(dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") - if(type && H5T_close(type) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dint.c b/src/H5Dint.c index 27072ab..537b7ed 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -2686,7 +2686,6 @@ hid_t H5D_get_type(H5D_t *dset) { H5T_t *dt = NULL; - H5T_t *type = NULL; hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT @@ -2712,14 +2711,7 @@ H5D_get_type(H5D_t *dset) /* If this is a committed datatype, we need to recreate the two level IDs, where the VOL object is a copy of the returned datatype */ - - /* Copy the dataset's datatype */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") - - H5T_set_vol_object(type, (void *)dt); - - if((ret_value = H5VL_native_register(H5I_DATATYPE, type, TRUE)) < 0) + if((ret_value = H5VL_native_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") } else { @@ -2730,8 +2722,6 @@ done: if(ret_value < 0) { if(dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") - if(type && H5T_close(type) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Doh.c b/src/H5Doh.c index da0be62..641c8b8 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -250,7 +250,7 @@ H5O__dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t a HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") /* Register an ID for the dataset */ - if((ret_value = H5VL_native_register(H5I_DATASET, dset, app_ref)) < 0) + if((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataset") done: diff --git a/src/H5Goh.c b/src/H5Goh.c index 30d9763..ebe30eb 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -225,7 +225,7 @@ H5O_group_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hb HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an ID for the group */ - if((ret_value = H5VL_native_register(H5I_GROUP, grp, app_ref)) < 0) + if((ret_value = H5I_register(H5I_GROUP, grp, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") done: diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 17bb5e1..ce3ded3 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -28,6 +28,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opublic.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLnative.h" /* Native Plugin */ #include "H5VLprivate.h" /* Virtual Object Layer */ static hid_t H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, @@ -441,6 +442,19 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, if((ext_obj = H5O_open_name(&root_loc, obj_name, lapl_id, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* get the native object from the ID created by the object header and create + a "VOL object" ID */ + { + void *temp_obj = NULL; + H5I_type_t obj_type; + obj_type = H5I_get_type(ext_obj); + if(NULL == (temp_obj = H5I_remove(ext_obj))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Get an atom for the datatype */ + if((ext_obj = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } + /* Set return value */ ret_value = ext_obj; diff --git a/src/H5O.c b/src/H5O.c index 2926c97..37ed9da 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -258,13 +258,8 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") - /* Get an atom for the object */ - if((ret_value = H5I_register2(opened_type, opened_obj, vol_plugin, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") -#if 0 - if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0) + if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") -#endif done: FUNC_LEAVE_API(ret_value) @@ -340,9 +335,8 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") - /* Get an atom for the object */ - if((ret_value = H5I_register2(opened_type, opened_obj, vol_plugin, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: FUNC_LEAVE_API(ret_value) @@ -412,9 +406,8 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") - /* Get an atom for the object */ - if((ret_value = H5I_register2(opened_type, opened_obj, vol_plugin, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: FUNC_LEAVE_API(ret_value) @@ -3492,19 +3485,41 @@ H5O_visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, /* (Takes ownership of the obj_loc information) */ if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") -#if 0 + + /* get the native object from the ID created by the object header and create + a "VOL object" ID */ { - H5I_type_t opened_type; - void *temp_obj = NULL; + void *temp_obj = NULL; + H5I_type_t obj_type; + obj_type = H5I_get_type(obj_id); + if(NULL == (temp_obj = H5I_remove(obj_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Get an atom for the datatype */ + if((obj_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } +#if 0 + /* if this is a named datatype, we need to create the two-fold datatype + to be comaptible with the VOL */ + if(H5I_DATATYPE == H5I_get_type(obj_id)) { + H5T_t *type = NULL; + void *temp_obj = NULL; - opened_type = H5I_get_type (obj_id); if(NULL == (temp_obj = H5I_remove(obj_id))) - HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") - /* get an ID for the object */ - if((ret_value = H5VL_native_register(opened_type, temp_obj, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + + /* Copy the dataset's datatype */ + if(NULL == (type = H5T_copy((H5T_t *)temp_obj, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") + + H5T_set_vol_object(type, temp_obj); + + /* Get an atom for the datatype */ + if((obj_id = H5VL_native_register(H5I_DATATYPE, type, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") } #endif + /* Make callback for starting object */ if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects") diff --git a/src/H5R.c b/src/H5R.c index dfb874e..d934a55 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -560,14 +560,10 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r /* Open the object through the VOL */ if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + /* Get an atom for the object */ - if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0) + if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") -#if 0 - /* Create reference */ - if((ret_value = H5R_dereference(file, oapl_id, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") -#endif done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index f55675e..8933ed5 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -231,7 +231,7 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") /* Get an atom for the object */ - if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0) + if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index f2d1743..0945dd0 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -628,7 +628,7 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open datatype") /* Get an atom for the datatype */ - if ((ret_value = H5VL_create_datatype(dt, vol_plugin, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_create_datatype(dt, vol_plugin, TRUE, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") done: @@ -956,7 +956,7 @@ H5T_get_named_type(const H5T_t *dt) *------------------------------------------------------------------------- */ hid_t -H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hid_t req) +H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hbool_t app_ref, hid_t req) { ssize_t nalloc; unsigned char *buf = NULL; @@ -984,7 +984,7 @@ H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hid_t req) H5MM_free(buf); /* Get an atom for the datatype with the VOL information as the auxilary struct*/ - if((ret_value = H5I_register2(H5I_DATATYPE, dt, vol_plugin, TRUE)) < 0) + if((ret_value = H5I_register2(H5I_DATATYPE, dt, vol_plugin, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") done: @@ -1017,7 +1017,7 @@ H5T_close_datatype(void *type, H5VL_t *vol_plugin) /* Close the datatype through the VOL*/ if (NULL != dt->vol_obj) if((ret_value = H5VL_datatype_close(dt->vol_obj, vol_plugin, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatypeibute") + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index bc8fb51..049c474 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -221,7 +221,7 @@ H5Topen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open datatype") /* Get an atom for the datatype */ - if ((ret_value = H5VL_create_datatype(dt, vol_plugin, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_create_datatype(dt, vol_plugin, TRUE, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") done: diff --git a/src/H5Toh.c b/src/H5Toh.c index 9c9313a..99cb396 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -133,7 +133,7 @@ done: static hid_t H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hbool_t app_ref) { - H5T_t *type = NULL, *dt = NULL; /* Datatype opened */ + H5T_t *dt = NULL; /* Datatype opened */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -144,22 +144,14 @@ H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hb if(NULL == (dt = H5T_open(obj_loc, dxpl_id))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open datatype") - /* Copy the dataset's datatype */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") - - H5T_set_vol_object(type, (void *)dt); - - /* Get an atom for the datatype */ - if((ret_value = H5VL_native_register(H5I_DATATYPE, type, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataset") + /* Register an ID for the datatype */ + if((ret_value = H5I_register(H5I_DATATYPE, dt, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: if(ret_value < 0) { if(dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") - if(type && H5T_close(type) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release datatype") } FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_dtype_open() */ diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index f4df875..9c74a76 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -141,7 +141,7 @@ H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc); H5_DLL H5T_t *H5T_decode(const unsigned char *buf); H5_DLL void * H5T_get_named_type(const H5T_t *dt); -H5_DLL hid_t H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hid_t req); +H5_DLL hid_t H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hbool_t app_ref, hid_t req); H5_DLL herr_t H5T_set_vol_object(H5T_t *type, void *vol_obj); /* Reference specific functions */ diff --git a/src/H5VL.c b/src/H5VL.c index b0b15a9..acdfdaa 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -344,59 +344,22 @@ done: *--------------------------------------------------------------------------- */ hid_t -H5VLregister_object(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls) +H5VLobject_register(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls) { H5VL_t *vol_plugin; /* VOL plugin information */ hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) - /* Get an atom for the object */ - if((ret_value = H5I_register(obj_type, obj, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object") - /* Build the vol plugin struct */ if(NULL == (vol_plugin = (H5VL_t *)H5MM_calloc(sizeof(H5VL_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") vol_plugin->cls = cls; vol_plugin->nrefs = 1; - switch(obj_type) { - case H5I_FILE: - if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5F_close_file) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - break; - case H5I_GROUP: - if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - break; - case H5I_DATATYPE: - if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - break; - case H5I_DATASET: - if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - break; - case H5I_ATTR: - if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - break; - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_VOL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - } /* end switch */ + if ((ret_value = H5VL_object_register(obj, obj_type, vol_plugin, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + done: FUNC_LEAVE_API(ret_value) } /* H5VLregister_object */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 08c539a..25b6fd2 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -368,7 +368,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin) +H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin, hbool_t app_ref) { hid_t ret_value = FAIL; @@ -377,21 +377,17 @@ H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin) /* Get an atom for the object and attach VOL information and free function to the ID */ switch(obj_type) { case H5I_GROUP: - if((ret_value = H5I_register(obj_type, obj, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object") - if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + if((ret_value = H5I_register2(obj_type, obj, vol_plugin, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") break; case H5I_DATASET: - if((ret_value = H5I_register(obj_type, obj, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object") - if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + if((ret_value = H5I_register2(obj_type, obj, vol_plugin, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") break; case H5I_DATATYPE: - if ((ret_value = H5VL_create_datatype(obj, vol_plugin, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_create_datatype(obj, vol_plugin, app_ref, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") break; @@ -413,7 +409,6 @@ H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "invalid object type") } /* end switch */ - vol_plugin->nrefs ++; done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_object_register() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 3f77d84..cdcfc3d 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -343,6 +343,7 @@ hid_t H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref) { H5VL_t *vol_plugin; /* VOL plugin information */ + H5T_t *dt = NULL; hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT @@ -355,12 +356,26 @@ H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref) vol_plugin->cls = &H5VL_native_g; vol_plugin->nrefs = 1; - /* Get an atom for the file with the VOL information as the auxilary struct*/ + /* if this is a named datatype, we need to create the two-fold datatype + to be comaptible with the VOL */ + if(H5I_DATATYPE == type) { + /* Copy the dataset's datatype */ + if(NULL == (dt = H5T_copy((H5T_t *)obj, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy datatype") + + H5T_set_vol_object(dt, obj); + obj = (void *) dt; + } + + /* Get an atom for the object with the VOL information as the auxilary struct*/ if((ret_value = H5I_register2(type, obj, (void *)vol_plugin, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + done: + if(ret_value < 0 && dt && H5T_close(dt) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) -} /* H5VL_native_register_with_aux */ +} /* H5VL_native_register */ /*------------------------------------------------------------------------- diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index c2c88f8..ed3719f 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -46,7 +46,7 @@ struct H5F_t; H5_DLL int H5VL_term_interface(void); H5_DLL H5VL_class_t *H5VL_get_class(hid_t id); H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); -H5_DLL hid_t H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin); +H5_DLL hid_t H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin, hbool_t app_ref); H5_DLL ssize_t H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size); H5_DLL void *H5VL_get_object(hid_t id); H5_DLL herr_t H5VL_close(H5VL_class_t *vol_plugin); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index add9ee0..2110295 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -382,7 +382,7 @@ H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); H5_DLL herr_t H5VLunregister(hid_t plugin_id); H5_DLL htri_t H5VLis_registered(hid_t id); H5_DLL ssize_t H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size); -H5_DLL hid_t H5VLregister_object(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls); +H5_DLL hid_t H5VLobject_register(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls); #ifdef __cplusplus } -- cgit v0.12