diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2008-08-19 16:36:55 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2008-08-19 16:36:55 (GMT) |
commit | 4b141cbc6a55a02b3191db75ef40450d4bc9d92d (patch) | |
tree | ca07875ee7b217123e5c330671a38da5bc33c2ae /src/H5R.c | |
parent | e660080290417487a8caf2b14055eda6b39e9f6e (diff) | |
download | hdf5-4b141cbc6a55a02b3191db75ef40450d4bc9d92d.zip hdf5-4b141cbc6a55a02b3191db75ef40450d4bc9d92d.tar.gz hdf5-4b141cbc6a55a02b3191db75ef40450d4bc9d92d.tar.bz2 |
[svn-r15486] Purpose: Allow library to shut down properly when objects have reference count
> 1.
Description: Added a new field 'app_count' to H5I_id_info_t struct, to track
the reference count on an id due to the application. the old 'count' field
tracks the total. Generally any id visible to the application gets placed
in app_count. Added app_ref boolean parameter to H5I_inc_ref, H5I_dec_ref,
H5I_register, H5I_clear_type, and a few other functions, to specify whether
the operation(s) being performed on the id(s) are due to the application
(TRUE) or not (FALSE). Test added for this case.
Tested: kagiso, smirom, linew (h5committest)
Diffstat (limited to 'src/H5R.c')
-rw-r--r-- | src/H5R.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -37,7 +37,8 @@ /* Static functions */ static herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); -static hid_t H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref); +static hid_t H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, + const void *_ref, hbool_t app_ref); static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref); static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size); @@ -123,7 +124,7 @@ H5R_term_interface(void) if (H5_interface_initialize_g) { if ((n=H5I_nmembers(H5I_REFERENCE))) { - H5I_clear_type(H5I_REFERENCE, FALSE); + H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); } else { H5I_dec_type_ref(H5I_REFERENCE); H5_interface_initialize_g = 0; @@ -359,7 +360,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hid_t -H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref) +H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref) { H5O_loc_t oloc; /* Object location */ H5G_name_t path; /* Path of object */ @@ -436,7 +437,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found") /* Create an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, group)) < 0) { + if((ret_value = H5I_register(H5I_GROUP, group, app_ref)) < 0) { H5G_close(group); HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "can't register group") } /* end if */ @@ -451,7 +452,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") /* Create an atom for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, type)) < 0) { + if((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0) { H5T_close(type); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register datatype") } /* end if */ @@ -467,7 +468,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") /* Create an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset)) < 0) { + if((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) { H5D_close(dset); HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset") } /* end if */ @@ -527,7 +528,7 @@ H5Rdereference(hid_t id, H5R_type_t ref_type, const void *_ref) file = loc.oloc->file; /* Create reference */ - if((ret_value = H5R_dereference(file, H5AC_dxpl_id, ref_type, _ref)) < 0) + if((ret_value = H5R_dereference(file, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object") done: @@ -650,7 +651,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace") /* Atomize */ - if((ret_value = H5I_register (H5I_DATASPACE, space)) < 0) + if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: @@ -881,7 +882,7 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty } /* end switch */ /* Retrieve file ID for name search */ - if((file_id = H5I_get_file_id(id)) < 0) + if((file_id = H5I_get_file_id(id, FALSE)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID") /* Get name, length, etc. */ @@ -891,7 +892,7 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty done: /* Close file ID used for search */ if(file_id > 0) - if(H5I_dec_ref(file_id) < 0) + if(H5I_dec_ref(file_id, FALSE) < 0) HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEFILE, FAIL, "can't determine name") FUNC_LEAVE_NOAPI(ret_value) |