diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 22 | ||||
-rw-r--r-- | src/H5AC.c | 16 | ||||
-rw-r--r-- | src/H5Aint.c | 11 | ||||
-rw-r--r-- | src/H5CS.c | 4 | ||||
-rw-r--r-- | src/H5D.c | 50 | ||||
-rw-r--r-- | src/H5Dchunk.c | 43 | ||||
-rw-r--r-- | src/H5Dcompact.c | 17 | ||||
-rw-r--r-- | src/H5Dcontig.c | 17 | ||||
-rw-r--r-- | src/H5Dfarray.c | 6 | ||||
-rw-r--r-- | src/H5Dfill.c | 6 | ||||
-rw-r--r-- | src/H5Dint.c | 27 | ||||
-rw-r--r-- | src/H5E.c | 27 | ||||
-rw-r--r-- | src/H5Eint.c | 6 | ||||
-rw-r--r-- | src/H5F.c | 12 | ||||
-rw-r--r-- | src/H5FD.c | 16 | ||||
-rw-r--r-- | src/H5FDfamily.c | 33 | ||||
-rw-r--r-- | src/H5Fsuper_cache.c | 12 | ||||
-rw-r--r-- | src/H5G.c | 9 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 2 | ||||
-rw-r--r-- | src/H5Gname.c | 4 | ||||
-rw-r--r-- | src/H5Gtraverse.c | 14 | ||||
-rw-r--r-- | src/H5HF.c | 6 | ||||
-rw-r--r-- | src/H5HFhdr.c | 3 | ||||
-rw-r--r-- | src/H5I.c | 289 | ||||
-rw-r--r-- | src/H5Iprivate.h | 4 | ||||
-rw-r--r-- | src/H5L.c | 4 | ||||
-rw-r--r-- | src/H5Lexternal.c | 4 | ||||
-rw-r--r-- | src/H5O.c | 4 | ||||
-rw-r--r-- | src/H5Ofill.c | 49 | ||||
-rw-r--r-- | src/H5Olink.c | 6 | ||||
-rw-r--r-- | src/H5P.c | 28 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 20 | ||||
-rw-r--r-- | src/H5Plapl.c | 16 | ||||
-rw-r--r-- | src/H5R.c | 5 | ||||
-rw-r--r-- | src/H5S.c | 8 | ||||
-rw-r--r-- | src/H5T.c | 48 | ||||
-rw-r--r-- | src/H5TS.c | 146 | ||||
-rw-r--r-- | src/H5TSprivate.h | 71 | ||||
-rw-r--r-- | src/H5Tcommit.c | 3 | ||||
-rw-r--r-- | src/H5Tconv.c | 12 | ||||
-rw-r--r-- | src/H5Z.c | 2 | ||||
-rw-r--r-- | src/H5private.h | 13 | ||||
-rw-r--r-- | src/H5public.h | 8 | ||||
-rw-r--r-- | src/Makefile.in | 2 |
44 files changed, 606 insertions, 499 deletions
@@ -1029,10 +1029,10 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) done: /* Release resources */ - if(src_id >= 0) - (void)H5I_dec_ref(src_id, FALSE); - if(dst_id >= 0) - (void)H5I_dec_ref(dst_id, FALSE); + if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") + if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") if(tconv_buf && !tconv_owned) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); if(bkg_buf) @@ -1175,10 +1175,10 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) done: /* Release resources */ - if(src_id >= 0) - (void)H5I_dec_ref(src_id, FALSE); - if(dst_id >= 0) - (void)H5I_dec_ref(dst_id, FALSE); + if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") + if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") if(tconv_buf) tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf); if(bkg_buf) @@ -2047,8 +2047,8 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, done: /* Release resources */ if(obj_loc_id > 0) { - if(H5I_dec_ref(obj_loc_id, TRUE) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close temporary object") + if(H5I_dec_app_ref(obj_loc_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") } /* end if */ else if(loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") @@ -2271,7 +2271,7 @@ H5Aclose(hid_t attr_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Decrement references to that atom (and close it) */ - if(H5I_dec_ref(attr_id, TRUE) < 0) + if(H5I_dec_app_ref(attr_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute") done: @@ -374,26 +374,26 @@ done: int H5AC_term_interface(void) { - int n=0; + int n = 0; FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5AC_term_interface) if (H5_interface_initialize_g) { #ifdef H5_HAVE_PARALLEL - if(H5AC_dxpl_id>0 || H5AC_noblock_dxpl_id>0 || H5AC_ind_dxpl_id>0) { + if(H5AC_dxpl_id > 0 || H5AC_noblock_dxpl_id > 0 || H5AC_ind_dxpl_id > 0) { /* Indicate more work to do */ n = 1; /* H5I */ /* Close H5AC dxpl */ - if (H5I_dec_ref(H5AC_dxpl_id, FALSE) < 0 || - H5I_dec_ref(H5AC_noblock_dxpl_id, FALSE) < 0 || - H5I_dec_ref(H5AC_ind_dxpl_id, FALSE) < 0) + if(H5I_dec_ref(H5AC_dxpl_id) < 0 || + H5I_dec_ref(H5AC_noblock_dxpl_id) < 0 || + H5I_dec_ref(H5AC_ind_dxpl_id) < 0) H5E_clear_stack(NULL); /*ignore error*/ else { /* Reset static IDs */ - H5AC_dxpl_id=(-1); - H5AC_noblock_dxpl_id=(-1); - H5AC_ind_dxpl_id=(-1); + H5AC_dxpl_id = (-1); + H5AC_noblock_dxpl_id = (-1); + H5AC_ind_dxpl_id = (-1); /* Reset interface initialization flag */ H5_interface_initialize_g = 0; diff --git a/src/H5Aint.c b/src/H5Aint.c index 101d604..30d662e 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1028,20 +1028,19 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si ret_value = attr_dst; done: - if(buf_sid > 0) - if(H5I_dec_ref(buf_sid, FALSE) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID") + if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary dataspace ID") if(tid_src > 0) /* Don't decrement ID, we want to keep underlying datatype */ - if(H5I_remove(tid_src) == NULL) + if(NULL == H5I_remove(tid_src)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") if(tid_dst > 0) /* Don't decrement ID, we want to keep underlying datatype */ - if(H5I_remove(tid_dst) == NULL) + if(NULL == H5I_remove(tid_dst)) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") if(tid_mem > 0) /* Decrement the memory datatype ID, it's transient */ - if(H5I_dec_ref(tid_mem, FALSE) < 0) + if(H5I_dec_ref(tid_mem) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID") if(buf) buf = H5FL_BLK_FREE(attr_buf, buf); @@ -81,7 +81,7 @@ H5CS_get_stack(void) FUNC_ENTER_NOAPI_NOFUNC_NOFS(H5CS_get_stack); - fstack = pthread_getspecific(H5TS_funcstk_key_g); + fstack = H5TS_get_thread_local_value(H5TS_funcstk_key_g); if (!fstack) { /* no associated value with current thread - create one */ fstack = (H5CS_t *)HDmalloc(sizeof(H5CS_t)); /* Don't use H5MM_malloc() here, it causes infinite recursion */ @@ -94,7 +94,7 @@ H5CS_get_stack(void) * released by the "key destructor" set up in the H5TS * routines. See calls to pthread_key_create() in H5TS.c -QAK) */ - pthread_setspecific(H5TS_funcstk_key_g, (void *)fstack); + H5TS_set_thread_local_value(H5TS_funcstk_key_g, (void *)fstack); } FUNC_LEAVE_NOAPI_NOFS(fstack); @@ -378,10 +378,14 @@ H5Dclose(hid_t dset_id) /* * Decrement the counter on the dataset. It will be freed if the count - * reaches zero. + * reaches zero. + * + * Pass in TRUE for the 3rd parameter to tell the function to remove + * dataset's ID even though the freeing function might fail. Please + * see the comments in H5I_dec_ref for details. (SLU - 2010/9/7) */ - if(H5I_dec_ref(dset_id, TRUE) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free") + if(H5I_dec_app_ref_always_close(dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID") done: FUNC_LEAVE_API(ret_value) @@ -604,30 +608,32 @@ H5Dget_create_plist(hid_t dset_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype") src_id = H5I_register(H5I_DATATYPE, H5T_copy(dset->shared->type, H5T_COPY_ALL), FALSE); if(src_id < 0) { - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype") } /* end if */ /* Allocate a background buffer */ bkg_size = MAX(H5T_GET_SIZE(copied_fill.type), H5T_GET_SIZE(dset->shared->type)); if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { - H5I_dec_ref(src_id, FALSE); - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(src_id); + H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ /* Convert fill value */ if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, copied_fill.buf, bkg_buf, H5AC_ind_dxpl_id) < 0) { - H5I_dec_ref(src_id, FALSE); - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(src_id); + H5I_dec_ref(dst_id); if(bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, FAIL, "datatype conversion failed") } /* end if */ /* Release local resources */ - H5I_dec_ref(src_id, FALSE); - H5I_dec_ref(dst_id, FALSE); + if(H5I_dec_ref(src_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") + if(H5I_dec_ref(dst_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") if(bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ @@ -643,7 +649,8 @@ H5Dget_create_plist(hid_t dset_id) done: if(ret_value < 0) if(new_dcpl_id > 0) - (void)H5I_dec_ref(new_dcpl_id, TRUE); + if(H5I_dec_app_ref(new_dcpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") FUNC_LEAVE_API(ret_value) } /* end H5Dget_create_plist() */ @@ -722,7 +729,8 @@ H5Dget_access_plist(hid_t dset_id) done: if(ret_value < 0) if(new_dapl_id >= 0) - (void)H5I_dec_ref(new_dapl_id, TRUE); + if(H5I_dec_app_ref(new_dapl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to close temporary object") FUNC_LEAVE_API(ret_value) } /* end H5Dget_access_plist() */ @@ -1028,22 +1036,16 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, *size = vlen_bufsize.size; done: - if(vlen_bufsize.fspace_id > 0) { - if(H5I_dec_ref(vlen_bufsize.fspace_id, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - } /* end if */ - if(vlen_bufsize.mspace_id > 0) { - if(H5I_dec_ref(vlen_bufsize.mspace_id, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - } /* end if */ + if(vlen_bufsize.fspace_id > 0 && H5I_dec_ref(vlen_bufsize.fspace_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + if(vlen_bufsize.mspace_id > 0 && H5I_dec_ref(vlen_bufsize.mspace_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") if(vlen_bufsize.fl_tbuf != NULL) vlen_bufsize.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.fl_tbuf); if(vlen_bufsize.vl_tbuf != NULL) vlen_bufsize.vl_tbuf = H5FL_BLK_FREE(vlen_vl_buf, vlen_bufsize.vl_tbuf); - if(vlen_bufsize.xfer_pid > 0) { - if(H5I_dec_ref(vlen_bufsize.xfer_pid, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref count on property list") - } /* end if */ + if(vlen_bufsize.xfer_pid > 0 && H5I_dec_ref(vlen_bufsize.xfer_pid) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref count on property list") FUNC_LEAVE_API(ret_value) } /* end H5Dvlen_get_buf_size() */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index d63497e..02de7ed 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -844,18 +844,14 @@ done: fm->file_space = NULL; fm->mem_space = NULL; - if(iter_init) { - if(H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") - } /* end if */ - if(f_tid!=(-1)) { - if(H5I_dec_ref(f_tid, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - } /* end if */ + if(iter_init && H5S_SELECT_ITER_RELEASE(&(fm->mem_iter)) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection iterator") + if(f_tid != (-1) && H5I_dec_ref(f_tid) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") if(file_space_normalized) { /* (Casting away const OK -QAK) */ if(H5S_hyper_denormalize_offset((H5S_t *)file_space, old_offset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") + HDONE_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -2571,7 +2567,7 @@ H5D_chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * if(flush) { /* Flush */ if(H5D_chunk_flush_entry(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) - HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") + HDONE_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") } /* end if */ else { /* Don't flush, just free chunk */ @@ -2585,7 +2581,7 @@ H5D_chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * if(dset->shared->layout.storage.u.chunk.ops->can_swim && (H5F_INTENT(dset->oloc.file) & H5F_ACC_SWMR_WRITE)) { /* Remove the proxy entry in the cache */ if(H5D_chunk_proxy_remove(dset, dxpl_id, ent) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't remove proxy for chunk from metadata cache") + HDONE_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't remove proxy for chunk from metadata cache") } /* end if */ /* Unlink from list */ @@ -2608,7 +2604,6 @@ H5D_chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t * /* Free */ ent = H5FL_FREE(H5D_rdcc_ent_t, ent); -done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_chunk_cache_evict() */ @@ -4232,9 +4227,6 @@ done: * To release the chunks, we traverse the B-tree to obtain a list of unused * allocated chunks, and then call H5B_remove() for each chunk. * - * Vailin Choi; August 2010 - * Added v2-btree indexing - * *------------------------------------------------------------------------- */ herr_t @@ -5320,17 +5312,14 @@ H5D_chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, bkg = udata.bkg; done: - if(sid_buf > 0 && H5I_dec_ref(sid_buf, FALSE) < 0) + if(sid_buf > 0 && H5I_dec_ref(sid_buf) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0) - if(H5I_dec_ref(tid_src, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0) - if(H5I_dec_ref(tid_dst, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0) - if(H5I_dec_ref(tid_mem, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") if(buf) H5MM_xfree(buf); if(bkg) @@ -5555,8 +5544,10 @@ H5D_chunk_dest(H5F_t *f, hid_t dxpl_id, H5D_t *dset) if(H5D_chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) nerrors++; } /* end for */ + + /* Continue even if there are failures. */ if(nerrors) - HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") + HDONE_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") /* Release cache structures */ if(rdcc->slot) diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index a9c0dd5..1e9c7ea 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -568,17 +568,14 @@ H5D_compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst, storage_dst->dirty = TRUE; done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid, FALSE) < 0) + if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0) - if(H5I_dec_ref(tid_src, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0) - if(H5I_dec_ref(tid_dst, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0) - if(H5I_dec_ref(tid_mem, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") if(buf) buf = H5FL_BLK_FREE(type_conv, buf); if(reclaim_buf) diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index b674f44..dcc7cdc 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -1450,17 +1450,14 @@ H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, } /* end while */ done: - if(buf_sid > 0 && H5I_dec_ref(buf_sid, FALSE) < 0) + if(buf_sid > 0 && H5I_dec_ref(buf_sid) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "can't decrement temporary dataspace ID") - if(tid_src > 0) - if(H5I_dec_ref(tid_src, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_dst > 0) - if(H5I_dec_ref(tid_dst, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(tid_mem > 0) - if(H5I_dec_ref(tid_mem, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_src > 0 && H5I_dec_ref(tid_src) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_dst > 0 && H5I_dec_ref(tid_dst) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") + if(tid_mem > 0 && H5I_dec_ref(tid_mem) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") if(buf) buf = H5FL_BLK_FREE(type_conv, buf); if(reclaim_buf) diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c index f260bcc..738a407 100644 --- a/src/H5Dfarray.c +++ b/src/H5Dfarray.c @@ -1119,9 +1119,9 @@ static int H5D_farray_idx_iterate_cb(hsize_t UNUSED idx, const void *_elmt, void *_udata) { H5D_farray_it_ud_t *udata = (H5D_farray_it_ud_t *)_udata; /* User data */ - unsigned ndims; /* Rank of chunk */ - int curr_dim; /* Current dimension */ - int ret_value; /* Return value */ + unsigned ndims; /* Rank of chunk */ + int curr_dim; /* Current dimension */ + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5D_farray_idx_iterate_cb) diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 1999dda..a80dd83 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -332,9 +332,9 @@ H5D_fill(const void *fill, const H5T_t *fill_type, void *buf, } /* end else */ done: - if(src_id != (-1) && H5I_dec_ref(src_id, FALSE) < 0) + if(src_id != (-1) && H5I_dec_ref(src_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") - if(dst_id != (-1) && H5I_dec_ref(dst_id, FALSE) < 0) + if(dst_id != (-1) && H5I_dec_ref(dst_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID") if(tmp_buf) tmp_buf = H5FL_BLK_FREE(type_conv, tmp_buf); @@ -693,7 +693,7 @@ H5D_fill_term(H5D_fill_buf_info_t *fb_info) /* Free other resources for vlen fill values */ if(fb_info->has_vlen_fill_type) { if(fb_info->mem_tid > 0) - H5I_dec_ref(fb_info->mem_tid, FALSE); + H5I_dec_ref(fb_info->mem_tid); else if(fb_info->mem_type) H5T_close(fb_info->mem_type); if(fb_info->bkg_buf) diff --git a/src/H5Dint.c b/src/H5Dint.c index 37db4e4..ff53db0 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -562,8 +562,8 @@ H5D_new(hid_t dcpl_id, hbool_t creating, hbool_t vl_type) done: if(ret_value == NULL) if(new_dset != NULL) { - if(new_dset->dcpl_id != 0) - (void)H5I_dec_ref(new_dset->dcpl_id, FALSE); + if(new_dset->dcpl_id != 0 && H5I_dec_ref(new_dset->dcpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement temporary datatype ID") new_dset = H5FL_FREE(H5D_shared_t, new_dset); } /* end if */ @@ -1174,10 +1174,8 @@ done: } /* end if */ if(new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") - if(new_dset->shared->type) { - if(H5I_dec_ref(new_dset->shared->type_id, FALSE) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") - } /* end if */ + if(new_dset->shared->type && H5I_dec_ref(new_dset->shared->type_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") if(H5F_addr_defined(new_dset->oloc.addr)) { if(H5O_close(&(new_dset->oloc)) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header") @@ -1186,7 +1184,7 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTDELETE, NULL, "unable to delete object header") } /* end if */ } /* end if */ - if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id, FALSE) < 0) + if(new_dset->shared->dcpl_id != 0 && H5I_dec_ref(new_dset->shared->dcpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement ref count on property list") new_dset->shared = H5FL_FREE(H5D_shared_t, new_dset->shared); } /* end if */ @@ -1437,7 +1435,7 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") if(dataset->shared->type) { if(dataset->shared->type_id > 0) { - if(H5I_dec_ref(dataset->shared->type_id, FALSE) < 0) + if(H5I_dec_ref(dataset->shared->type_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") } /* end if */ else { @@ -1485,9 +1483,9 @@ H5D_close(H5D_t *dataset) dataset->shared->fo_count--; if(dataset->shared->fo_count == 0) { - /* Flush the dataset's information */ + /* Flush the dataset's information. Continue to close even if it fails. */ if(H5D_flush_real(dataset, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") + HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") /* Free the data sieve buffer, if it's been allocated */ if(dataset->shared->cache.contig.sieve_buf) { @@ -1521,9 +1519,10 @@ H5D_close(H5D_t *dataset) dataset->shared->cache.chunk.single_chunk_info = NULL; } /* end if */ - /* Flush and destroy chunks in the cache */ + /* Flush and destroy chunks in the cache. Continue to close even if + * it fails. */ if(H5D_chunk_dest(dataset->oloc.file, H5AC_dxpl_id, dataset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to destroy chunk cache") break; case H5D_COMPACT: @@ -1549,8 +1548,8 @@ H5D_close(H5D_t *dataset) * Release datatype, dataspace and creation property list -- there isn't * much we can do if one of these fails, so we just continue. */ - free_failed = (unsigned)(H5I_dec_ref(dataset->shared->type_id, FALSE) < 0 || H5S_close(dataset->shared->space) < 0 || - H5I_dec_ref(dataset->shared->dcpl_id, FALSE) < 0); + free_failed = (unsigned)(H5I_dec_ref(dataset->shared->type_id) < 0 || H5S_close(dataset->shared->space) < 0 || + H5I_dec_ref(dataset->shared->dcpl_id) < 0); /* Remove the dataset from the list of opened objects in the file */ if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0) @@ -336,7 +336,7 @@ H5E_get_stack(void) FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5E_get_stack) - estack = (H5E_t *)pthread_getspecific(H5TS_errstk_key_g); + estack = (H5E_t *)H5TS_get_thread_local_value(H5TS_errstk_key_g); if(!estack) { /* no associated value with current thread - create one */ @@ -351,7 +351,7 @@ H5E_get_stack(void) * released by the "key destructor" set up in the H5TS * routines. See calls to pthread_key_create() in H5TS.c -QAK) */ - pthread_setspecific(H5TS_errstk_key_g, (void *)estack); + H5TS_set_thread_local_value(H5TS_errstk_key_g, (void *)estack); } /* end if */ /* Set return value */ @@ -505,7 +505,7 @@ H5Eunregister_class(hid_t class_id) * Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ - if(H5I_dec_ref(class_id, TRUE) < 0) + if(H5I_dec_app_ref(class_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") done: @@ -684,7 +684,7 @@ H5Eclose_msg(hid_t err_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error class") /* Decrement the counter. It will be freed if the count reaches zero. */ - if(H5I_dec_ref(err_id, TRUE) < 0) + if(H5I_dec_app_ref(err_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") done: @@ -1000,13 +1000,19 @@ done: /*------------------------------------------------------------------------- * Function: H5Eset_current_stack * - * Purpose: Replaces current stack with specified stack. + * Purpose: Replaces current stack with specified stack. This closes the + * stack ID also. * * Return: Non-negative value on success/Negative on failure * * Programmer: Raymond Lu * Friday, July 15, 2003 * + * Modification: + * Raymond Lu + * 7 September 2010 + * Also closes the stack to avoid potential problem (bug 1799) + * *------------------------------------------------------------------------- */ herr_t @@ -1025,6 +1031,13 @@ H5Eset_current_stack(hid_t err_stack) /* Set the current error stack */ if(H5E_set_current_stack(estack) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTSET, FAIL, "unable to set error stack") + + /* + * Decrement the counter on the error stack. It will be freed if the count + * reaches zero. + */ + if(H5I_dec_app_ref(err_stack) < 0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack") } /* end if */ done: @@ -1118,14 +1131,14 @@ H5Eclose_stack(hid_t stack_id) if(H5E_DEFAULT != stack_id) { /* Check arguments */ - if (H5I_ERROR_STACK != H5I_get_type(stack_id)) + if(H5I_ERROR_STACK != H5I_get_type(stack_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") /* * Decrement the counter on the error stack. It will be freed if the count * reaches zero. */ - if(H5I_dec_ref(stack_id, TRUE)<0) + if(H5I_dec_app_ref(stack_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack") } /* end if */ diff --git a/src/H5Eint.c b/src/H5Eint.c index 0bf9083..584ba40 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -892,11 +892,11 @@ H5E_clear_entries(H5E_t *estack, size_t nentries) /* Decrement the IDs to indicate that they are no longer used by this stack */ /* (In reverse order that they were incremented, so that reference counts work well) */ - if(H5I_dec_ref(error->min_num, FALSE) < 0) + if(H5I_dec_ref(error->min_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->maj_num, FALSE) < 0) + if(H5I_dec_ref(error->maj_num) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message") - if(H5I_dec_ref(error->cls_id, FALSE) < 0) + if(H5I_dec_ref(error->cls_id) < 0) HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class") /* Release strings */ @@ -1062,10 +1062,10 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) /* Destroy file creation properties */ if(H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id)) /* Push error, but keep going*/ - HDONE_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") - if(H5I_dec_ref(f->shared->fcpl_id, FALSE) < 0) + HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a property list") + if(H5I_dec_ref(f->shared->fcpl_id) < 0) /* Push error, but keep going*/ - HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list") + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list") /* Only truncate the file on an orderly close, with write-access */ if(f->closing && (H5F_ACC_RDWR & H5F_INTENT(f))) { @@ -1887,7 +1887,7 @@ H5F_try_close(H5F_t *f) while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_ATTR, (int)(sizeof(objs)/sizeof(objs[0])), objs, FALSE)) != 0) { /* Try to close all the open objects in this file */ for(u = 0; u < obj_count; u++) - if(H5I_dec_ref(objs[u], FALSE) < 0) + if(H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ @@ -1899,7 +1899,7 @@ H5F_try_close(H5F_t *f) while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATATYPE, (int)(sizeof(objs)/sizeof(objs[0])), objs, FALSE)) != 0) { /* Try to close all the open objects in this file */ for(u = 0; u < obj_count; u++) - if(H5I_dec_ref(objs[u], FALSE) < 0) + if(H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") } /* end while */ } /* end if */ @@ -1986,7 +1986,7 @@ H5Fclose(hid_t file_id) * Decrement reference count on atom. When it reaches zero the file will * be closed. */ - if(H5I_dec_ref(file_id, TRUE) < 0) + if(H5I_dec_app_ref(file_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") done: @@ -396,29 +396,27 @@ done: * Programmer: Robb Matzke * Monday, July 26, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5FDunregister(hid_t driver_id) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5FDunregister, FAIL) H5TRACE1("e", "i", driver_id); /* Check arguments */ - if(NULL==H5I_object_verify(driver_id,H5I_VFL)) + if(NULL == H5I_object_verify(driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver") /* The H5FD_class_t struct will be freed by this function */ - if(H5I_dec_ref(driver_id, TRUE) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to unregister file driver") + if(H5I_dec_app_ref(driver_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "unable to unregister file driver") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5FDunregister() */ /*------------------------------------------------------------------------- @@ -660,7 +658,7 @@ H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), void *pl) H5MM_xfree(pl); /* Decrement reference count for driver */ - if(H5I_dec_ref(driver_id, FALSE) < 0) + if(H5I_dec_ref(driver_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement reference count for driver") done: @@ -1187,7 +1185,7 @@ H5FD_close(H5FD_t *file) /* Prepare to close file by clearing all public fields */ driver = file->cls; - if(H5I_dec_ref(file->driver_id, FALSE) < 0) + if(H5I_dec_ref(file->driver_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") /* diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 67bb107..bd09ea4 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -468,11 +468,11 @@ static herr_t H5FD_family_fapl_free(void *_fa) { H5FD_family_fapl_t *fa = (H5FD_family_fapl_t*)_fa; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_fapl_free, FAIL) - if(H5I_dec_ref(fa->memb_fapl_id, FALSE)<0) + if(H5I_dec_ref(fa->memb_fapl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(fa); @@ -554,11 +554,11 @@ static herr_t H5FD_family_dxpl_free(void *_dx) { H5FD_family_dxpl_t *dx = (H5FD_family_dxpl_t*)_dx; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5FD_family_dxpl_free, FAIL) - if(H5I_dec_ref(dx->memb_dxpl_id, FALSE)<0) + if(H5I_dec_ref(dx->memb_dxpl_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(dx); @@ -855,29 +855,30 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id, done: /* Cleanup and fail */ - if (ret_value==NULL && file!=NULL) { - unsigned nerrors=0; /* Number of errors closing member files */ + if(ret_value == NULL && file != NULL) { + unsigned nerrors = 0; /* Number of errors closing member files */ unsigned u; /* Local index variable */ /* Close as many members as possible. Use private function here to avoid clearing * the error stack. We need the error message to indicate wrong member file size. */ - for (u=0; u<file->nmembs; u++) - if (file->memb[u]) - if (H5FD_close(file->memb[u])<0) + for(u = 0; u < file->nmembs; u++) + if(file->memb[u]) + if(H5FD_close(file->memb[u]) < 0) nerrors++; - if (nerrors) + if(nerrors) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "unable to close member files") - if (file->memb) + if(file->memb) H5MM_xfree(file->memb); - if(H5I_dec_ref(file->memb_fapl_id, FALSE)<0) + if(H5I_dec_ref(file->memb_fapl_id) < 0) HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID") - if (file->name) + if(file->name) H5MM_xfree(file->name); H5MM_xfree(file); - } + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_family_open() */ /*------------------------------------------------------------------------- @@ -921,7 +922,7 @@ H5FD_family_close(H5FD_t *_file) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files") /* Clean up other stuff */ - if(H5I_dec_ref(file->memb_fapl_id, FALSE) < 0) + if(H5I_dec_ref(file->memb_fapl_id) < 0) /* Push error, but keep going*/ HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") H5MM_xfree(file->memb); diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 68e5551..4212f97 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -448,6 +448,8 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) /* Get the B-tree internal node values, etc */ if(H5P_get(c_plist, H5F_CRT_BTREE_RANK_NAME, sblock->btree_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes") + if(H5P_get(c_plist, H5F_CRT_SYM_LEAF_NAME, &sblock->sym_leaf_k) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes") } /* end else */ /* @@ -566,12 +568,6 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) if(H5P_set(c_plist, H5F_CRT_SYM_LEAF_NAME, &btreek.sym_leaf_k) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for symbol table leaf nodes") } /* end if */ - else { - /* No non-default v1 B-tree 'K' value info in file, use defaults */ - sblock->btree_k[H5B_CHUNK_ID] = HDF5_BTREE_CHUNK_IK_DEF; - sblock->btree_k[H5B_SNODE_ID] = HDF5_BTREE_SNODE_IK_DEF; - sblock->sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; - } /* end if */ /* Check for the extension having a 'free-space manager info' message */ if((status = H5O_msg_exists(&ext_loc, H5O_FSINFO_ID, dxpl_id)) < 0) @@ -603,10 +599,6 @@ H5F_sblock_load(H5F_t *f, hid_t dxpl_id, haddr_t UNUSED addr, void *_udata) for(u = 1; u < NELMTS(f->shared->fs_addr); u++) shared->fs_addr[u] = fsinfo.fs_addr[u-1]; } /* end if */ - else { - for(u = 0; u < NELMTS(f->shared->fs_addr); u++) - shared->fs_addr[u] = HADDR_UNDEF; - } /* end else */ /* Close superblock extension */ if(H5F_super_ext_close(f, &ext_loc) < 0) @@ -504,7 +504,8 @@ H5Gget_create_plist(hid_t group_id) done: if(ret_value < 0) { if(new_gcpl_id > 0) - (void)H5I_dec_ref(new_gcpl_id, TRUE); + if(H5I_dec_app_ref(new_gcpl_id) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") } /* end if */ FUNC_LEAVE_API(ret_value) @@ -714,7 +715,7 @@ H5Gclose(hid_t group_id) * Decrement the counter on the group atom. It will be freed if the count * reaches zero. */ - if(H5I_dec_ref(group_id, TRUE) < 0) + if(H5I_dec_app_ref(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") done: @@ -1536,7 +1537,7 @@ H5G_iterate(hid_t loc_id, const char *group_name, done: /* Release the group opened */ if(gid > 0) { - if(H5I_dec_ref(gid, TRUE) < 0) + if(H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } /* end if */ else if(grp && H5G_close(grp) < 0) @@ -1869,7 +1870,7 @@ done: /* Release the group opened */ if(gid > 0) { - if(H5I_dec_ref(gid, TRUE) < 0) + if(H5I_dec_app_ref(gid) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") } /* end if */ else if(grp && H5G_close(grp) < 0) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 6629934..c905722 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -253,7 +253,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) done: if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) - if(H5I_dec_ref(tmp_gcpl, FALSE) < 0) + if(H5I_dec_ref(tmp_gcpl) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list") if(ret_value < 0) diff --git a/src/H5Gname.c b/src/H5Gname.c index 96b2e3a..c7feb62 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -461,12 +461,12 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, /* Search for name of object */ if((len = H5G_get_name_by_addr(file, lapl_id, dxpl_id, loc->oloc, name, size)) < 0) { - H5I_dec_ref(file, FALSE); + H5I_dec_ref(file); HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name") } /* end if */ /* Close file ID used for search */ - if(H5I_dec_ref(file, FALSE) < 0) + if(H5I_dec_ref(file) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name") /* Indicate that the name is _not_ cached, if requested */ diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 742e2bc..d8cf0f3 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -270,22 +270,20 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, /* We have a copy of the location and we're holding the file open. * Close the open ID the user passed back. */ - if(H5I_dec_ref(cb_return, FALSE) < 0) + if(H5I_dec_ref(cb_return) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") cb_return = (-1); done: /* Close location given to callback. */ - if(cur_grp > 0) - if(H5I_dec_ref(cur_grp, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom for current location") + if(cur_grp > 0 && H5I_dec_ref(cur_grp) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom for current location") - if(ret_value < 0 && cb_return > 0) - if(H5I_dec_ref(cb_return, FALSE) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") + if(ret_value < 0 && cb_return > 0 && H5I_dec_ref(cb_return) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") /* Close the LAPL, if we copied one */ - if(lapl_id > 0 && H5I_dec_ref(lapl_id, FALSE) < 0) + if(lapl_id > 0 && H5I_dec_ref(lapl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close copied link access property list") FUNC_LEAVE_NOAPI(ret_value) @@ -859,9 +859,6 @@ HDfprintf(stderr, "%s; After iterator reset fh->hdr->rc = %Zu\n", FUNC, fh->hdr- if(NULL == (hdr = H5HF_hdr_protect(fh->f, dxpl_id, heap_addr, H5AC_WRITE))) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect fractal heap header") - /* Set the shared heap header's file context for this operation */ - hdr->f = fh->f; - /* Delete heap, starting with header (unprotects header) */ if(H5HF_hdr_delete(hdr, dxpl_id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") @@ -913,9 +910,6 @@ HDfprintf(stderr, "%s: fh_addr = %a\n", FUNC, fh_addr); if(hdr->file_rc) hdr->pending_delete = TRUE; else { - /* Set the shared heap header's file context for this operation */ - hdr->f = f; - /* Delete heap now, starting with header (unprotects header) */ if(H5HF_hdr_delete(hdr, dxpl_id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDELETE, FAIL, "unable to delete fractal heap") diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index e678d74..684c171 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -552,6 +552,9 @@ H5HF_hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5AC_protect_t rw) /* Set the header's address */ hdr->heap_addr = addr; + /* Update header's file pointer */ + hdr->f = f; + /* Set the return value */ ret_value = hdr; @@ -165,9 +165,7 @@ H5I_init_interface(void) * * Failure: Negative. * - * Programmer: - * - * Modifications: + * Programmer: Unknown * *------------------------------------------------------------------------- */ @@ -217,15 +215,12 @@ H5I_term_interface(void) * the type. * * Return: Success: Type ID of the new type - * * Failure: H5I_BADID * * Programmers: Nathaniel Furrer - * James Laird + * James Laird * Friday, April 30, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ H5I_type_t @@ -263,22 +258,9 @@ done: * Failure: H5I_BADID * * Programmers: Nathaniel Furrer - * James Laird + * James Laird * Friday, April 30, 2004 * - * Modifications: The initialization section of this function was formerly - * H5I_init_type, programmed by Robb Matzke on February 19, - * 1999. - * - * Bill Wendling, 2000-05-05 - * Instead of the ugly test of whether hash_size is a power of - * two, I placed it in a macro POWER_OF_TWO which uses the fact - * that a number that is a power of two has only 1 bit set. - * - * Bill Wendling, 2000-05-09 - * Changed POWER_OF_TWO macro to allow 1 as a valid power of two. - * Changed test below accordingly. - * *------------------------------------------------------------------------- */ H5I_type_t @@ -376,15 +358,12 @@ done: * currently registered with the library. * * Return: Success: 1 if the type is registered, 0 if it is not - * * Failure: Negative * * Programmer: James Laird * Nathaniel Furrer * Tuesday, June 29, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ htri_t @@ -415,19 +394,12 @@ done: * private interface, which will just return 0. * * Return: Success: Zero - * * Failure: Negative * * Programmer: James Laird * Nathaniel Furrer * Friday, April 23, 2004 * - * Modifications: - * June 29, 2004 - * Nat Furrer and James Laird - * Changed function signature to return the number of members - * by reference. - * *------------------------------------------------------------------------- */ herr_t @@ -477,8 +449,6 @@ done: * Programmer: Robb Matzke * Wednesday, March 24, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -510,14 +480,12 @@ done: * Public interface to H5I_clear_type. * * Return: Success: Non-negative - * * Failure: negative * * Programmer: James Laird - * Nathaniel Furrer + * Nathaniel Furrer * Friday, April 23, 2004 * - * Modifications: *------------------------------------------------------------------------- */ herr_t @@ -545,7 +513,6 @@ done: * function for each object regardless of the reference count. * * Return: Success: Non-negative - * * Failure: negative * * Programmer: Robb Matzke @@ -699,8 +666,6 @@ done: * Programmer: Nathaniel Furrer * James Laird * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -734,8 +699,6 @@ done: * Programmer: Nathaniel Furrer * James Laird * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -773,13 +736,10 @@ done: * Purpose: Public interface to H5I_register. * * Return: Success: New object id. - * * Failure: Negative * * Programmer: Nathaniel Furrer - * James Laird - * - * Modifications: + * James Laird * *------------------------------------------------------------------------- */ @@ -813,7 +773,6 @@ done: * the ID which is returned to the user. * * Return: Success: New object id. - * * Failure: Negative * * Programmer: Unknown @@ -969,12 +928,9 @@ done: * * Return: Success: Non-null object pointer associated with the * specified ID. - * * Failure: NULL * - * Programmer: - * - * Modifications: + * Programmer: Unknown * *------------------------------------------------------------------------- */ @@ -1007,15 +963,12 @@ done: * * Return: Success: Non-null object pointer associated with the * specified ID. - * * Failure: NULL * * Programmer: Nathaniel Furrer * James Laird * Friday, April 23, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ void * @@ -1046,14 +999,11 @@ done: * * Return: Success: Non-null object pointer associated with the * specified ID. - * * Failure: NULL * * Programmer: Quincey Koziol * Wednesday, July 31, 2002 * - * Modifications: - * *------------------------------------------------------------------------- */ void * @@ -1087,14 +1037,11 @@ done: * in the object ID. * * Return: Success: A valid type number - * * Failure: H5I_BADID, a negative value. * * Programmer: Robb Matzke * Friday, February 19, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ H5I_type_t @@ -1123,15 +1070,10 @@ done: * encoded as part of the ID. * * Return: Success: Type number - * * Failure: H5I_BADID, a negative value * - * Programmer: + * Programmer: Unknown * - * Modifications: - * Robb Matzke, 1999-08-23 - * Also fails if the ID has a valid type but no longer exists - * in the ID tables. *------------------------------------------------------------------------- */ H5I_type_t @@ -1162,13 +1104,10 @@ done: * Return: Success: A pointer to the object that was removed, the * same pointer which would have been found by * calling H5I_object(). - * * Failure: NULL * * Programmer: James Laird - * Nathaniel Furrer - * - * Modifications: + * Nathaniel Furrer * *------------------------------------------------------------------------- */ @@ -1199,13 +1138,10 @@ done: * Return: Success: A pointer to the object that was removed, the * same pointer which would have been found by * calling H5I_object(). - * * Failure: NULL * * Programmer: James Laird - * Nat Furrer - * - * Modifications: + * Nat Furrer * *------------------------------------------------------------------------- */ @@ -1236,12 +1172,9 @@ done: * Return: Success: A pointer to the object that was removed, the * same pointer which would have been found by * calling H5I_object(). - * * Failure: NULL * - * Programmer: - * - * Modifications: + * Programmer: Unknown * *------------------------------------------------------------------------- */ @@ -1330,7 +1263,7 @@ H5Idec_ref(hid_t id) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") /* Do actual decrement operation */ - if((ret_value = H5I_dec_ref(id, TRUE)) < 0) + if((ret_value = H5I_dec_app_ref(id)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") done: @@ -1353,36 +1286,10 @@ done: * * Programmer: Unknown * - * Modifications: - * - * Robb Matzke, 19 Feb 1998 - * It is no longer an error when the reference count of an item reaches - * zero and no `free' function has been defined. The object is still - * removed from the list. - * - * Robb Matzke, 30 Dec 1998 - * Fixed a bug where the return value was always zero instead of the new - * reference count. - * - * Robb Matzke, 19 Feb 1999 - * If the free method is defined and fails then the object is not - * removed from the type and its reference count is not decremented. - * The type number is now passed to the free method. - * - * Raymond, 11 Dec 2001 - * If the freeing function fails, return failure instead of reference - * count 1. This feature is needed by file close with H5F_CLOSE_SEMI - * value. - * - * Neil Fortner, 7 Aug 2008 - * Added app_ref parameter and support for the app_count field, to - * distiguish between reference count from the library and from the - * application. - * *------------------------------------------------------------------------- */ int -H5I_dec_ref(hid_t id, hbool_t app_ref) +H5I_dec_ref(hid_t id) { H5I_type_t type; /*type the object is in*/ H5I_id_type_t *type_ptr; /*ptr to the type */ @@ -1403,7 +1310,7 @@ H5I_dec_ref(hid_t id, hbool_t app_ref) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") /* General lookup of the ID */ - if(NULL == (id_ptr=H5I_find_id(id))) + if(NULL == (id_ptr = H5I_find_id(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") /* @@ -1415,6 +1322,11 @@ H5I_dec_ref(hid_t id, hbool_t app_ref) * reference count without calling the free method. * * Beware: the free method may call other H5I functions. + * + * If an object is closing, we can remove the ID even though the free + * method might fail. This can happen when a mandatory filter fails to + * write when a dataset is closed and the chunk cache is flushed to the + * file. We have to close the dataset anyway. (SLU - 2010/9/7) */ if(1 == id_ptr->count) { /* (Casting away const OK -QAK) */ @@ -1427,11 +1339,8 @@ H5I_dec_ref(hid_t id, hbool_t app_ref) } /* end if */ else { --(id_ptr->count); - if(app_ref) - --(id_ptr->app_count); - HDassert(id_ptr->count >= id_ptr->app_count); - ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); - } + ret_value = (int)id_ptr->count; + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1439,6 +1348,99 @@ done: /*------------------------------------------------------------------------- + * Function: H5I_dec_app_ref + * + * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. + * count for an ID as well as normal reference count. + * + * Return: Success: New app. reference count. + * Failure: Negative + * + * Programmer: Quincey Koziol + * Sept 16, 2010 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_app_ref(hid_t id) +{ + H5I_id_info_t *id_ptr; /*ptr to the new ID */ + int ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_dec_app_ref, FAIL) + + /* Sanity check */ + HDassert(id >= 0); + + /* Call regular decrement reference count routine */ + if((ret_value = H5I_dec_ref(id)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + + /* Check if the ID still exists */ + if(ret_value > 0) { + /* General lookup of the ID */ + if(NULL == (id_ptr = H5I_find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + + /* Adjust app_ref */ + --(id_ptr->app_count); + HDassert(id_ptr->count >= id_ptr->app_count); + + /* Set return value */ + ret_value = (int)id_ptr->app_count; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_app_ref() */ + + +/*------------------------------------------------------------------------- + * Function: H5I_dec_app_ref_always_close + * + * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, + * even when the free routine fails + * + * Return: Success: New app. reference count. + * Failure: Negative + * + * Programmer: Quincey Koziol + * Sept 16, 2010 + * + *------------------------------------------------------------------------- + */ +int +H5I_dec_app_ref_always_close(hid_t id) +{ + int ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_dec_app_ref_always_close, FAIL) + + /* Sanity check */ + HDassert(id >= 0); + + /* Call application decrement reference count routine */ + ret_value = H5I_dec_app_ref(id); + + /* Check for failure */ + if(ret_value < 0) { + /* + * If an object is closing, we can remove the ID even though the free + * method might fail. This can happen when a mandatory filter fails to + * write when a dataset is closed and the chunk cache is flushed to the + * file. We have to close the dataset anyway. (SLU - 2010/9/7) + */ + H5I_remove(id); + + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_dec_app_ref_always_close() */ + + +/*------------------------------------------------------------------------- * Function: H5Iinc_ref * * Purpose: Increments the number of references outstanding for an ID. @@ -1449,8 +1451,6 @@ done: * Programmer: Quincey Koziol * Dec 7, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1480,7 +1480,6 @@ done: * Purpose: Increment the reference count for an object. * * Return: Success: The new reference count. - * * Failure: Negative * * Programmer: Robb Matzke @@ -1544,8 +1543,6 @@ done: * Programmer: Quincey Koziol * Dec 7, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1575,7 +1572,6 @@ done: * Purpose: Retrieve the reference count for an object. * * Return: Success: The reference count. - * * Failure: Negative * * Programmer: Quincey Koziol @@ -1632,11 +1628,9 @@ done: * Failure: Negative * * Programmer: Nat Furrer - * James Laird + * James Laird * April 30, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1669,15 +1663,12 @@ done: * Purpose: Increment the reference count for an ID type. * * Return: Success: The new reference count. - * * Failure: Negative * * Programmer: James Laird - * Nat Furrer + * Nat Furrer * Friday, April 30, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1722,9 +1713,7 @@ done: * Return: Number of references to type on success/Negative on failure * * Programmer: Nathaniel Furrer - * James Laird - * - * Modifications: + * James Laird * *------------------------------------------------------------------------- */ @@ -1764,11 +1753,6 @@ done: * * Programmer: Unknown * - * Modifications: - * - * Robb Matzke, 25 Feb 1998 - * IDs are freed when a type is destroyed. - * *------------------------------------------------------------------------- */ herr_t @@ -1815,11 +1799,9 @@ done: * Failure: Negative * * Programmer: Nat Furrer - * James Laird + * James Laird * April 30, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1856,11 +1838,9 @@ done: * Failure: Negative * * Programmer: Nat Furrer - * James Laird + * James Laird * April 30, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1900,12 +1880,6 @@ done: * Programmer: Neil Fortner * Friday, October 31, 2008 (boo) * - * Modifications: - * Raymond Lu - * 1 April 2009 (Believe it or not!) - * Moved the argument check down to H5I_find_id because other - * caller functions may pass in some invalid IDs to H5I_find_id. - * It used to do assertion check. *------------------------------------------------------------------------- */ htri_t @@ -1986,7 +1960,6 @@ done: * Return: Success: The first object in the type for which FUNC * returns non-zero. NULL if FUNC returned zero * for every object in the type. - * * Failure: NULL * * Programmer: Robb Matzke @@ -2049,12 +2022,8 @@ done: * * Failure: NULL * - * Programmer: + * Programmer: Unknown * - * Modifications: - * Raymond Lu - * 1 April 2009 (Believe it or not!) - * Added argument check, took away assertion check. *------------------------------------------------------------------------- */ static H5I_id_info_t * @@ -2166,8 +2135,6 @@ done: * Programmer: Raymond Lu * Oct 27, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -2238,21 +2205,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_debug - * - * Purpose: Dump the contents of a type to stderr for debugging. + * Function: H5I_debug * - * Return: Success: Non-negative + * Purpose: Dump the contents of a type to stderr for debugging. * - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * - * Programmer: Robb Matzke - * Friday, February 19, 1999 - * - * Modifications: - * - * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002 - * Added `id to name' support. + * Programmer: Robb Matzke + * Friday, February 19, 1999 * *------------------------------------------------------------------------- */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index ef83908..98423df 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -65,7 +65,9 @@ H5_DLL void *H5I_remove_verify(hid_t id, H5I_type_t id_type); H5_DLL void *H5I_search(H5I_type_t type, H5I_search_func_t func, void *key, hbool_t app_ref); H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); -H5_DLL int H5I_dec_ref(hid_t id, hbool_t app_ref); +H5_DLL int H5I_dec_ref(hid_t id); +H5_DLL int H5I_dec_app_ref(hid_t id); +H5_DLL int H5I_dec_app_ref_always_close(hid_t id); H5_DLL int H5I_inc_type_ref(H5I_type_t type); H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); H5_DLL int H5I_get_type_ref(H5I_type_t type); @@ -1762,7 +1762,7 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED done: /* Close the location given to the user callback if it was created */ if(grp_id >= 0) { - if(H5I_dec_ref(grp_id, TRUE) < 0) + if(H5I_dec_app_ref(grp_id) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") } /* end if */ else if(grp != NULL) { @@ -2464,7 +2464,7 @@ H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, done: /* Close the location given to the user callback if it was created */ if(grp_id >= 0) { - if(H5I_dec_ref(grp_id, TRUE) < 0) + if(H5I_dec_app_ref(grp_id) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback") } /* end if */ else if(grp != NULL) { diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index d98a843..9cab8cf 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -453,7 +453,7 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, done: /* Release resources */ - if(fapl_id > 0 && H5I_dec_ref(fapl_id, FALSE) < 0) + if(fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") if(ext_file && H5F_try_close(ext_file) < 0) HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, FAIL, "problem closing external file") @@ -465,7 +465,7 @@ done: if(ret_value < 0) { /* Close object if it's open and something failed */ - if(ext_obj >= 0 && H5I_dec_ref(ext_obj, FALSE) < 0) + if(ext_obj >= 0 && H5I_dec_ref(ext_obj) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for external object") } /* end if */ @@ -1059,7 +1059,7 @@ H5Oclose(hid_t object_id) case H5I_DATASET: if(H5I_object(object_id) == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") - if(H5I_dec_ref(object_id, TRUE) < 0) + if(H5I_dec_app_ref(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") break; @@ -3338,7 +3338,7 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, done: if(obj_id > 0) { - if(H5I_dec_ref(obj_id, TRUE) < 0) + if(H5I_dec_app_ref(obj_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") } /* end if */ else if(loc_found && H5G_loc_free(&obj_loc) < 0) diff --git a/src/H5Ofill.c b/src/H5Ofill.c index ebe1eb5..c7c743a 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -525,7 +525,7 @@ H5O_fill_copy(const void *_src, void *_dst) /* Set up type conversion function */ if(NULL == (tpath = H5T_path_find(src->type, dst->type, NULL, NULL, H5AC_ind_dxpl_id, FALSE))) - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "unable to convert between src and dst data types") + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, NULL, "unable to convert between src and dst data types") /* If necessary, convert fill value datatypes (which copies VL components, etc.) */ if(!H5T_path_noop(tpath)) { @@ -536,33 +536,33 @@ H5O_fill_copy(const void *_src, void *_dst) /* Wrap copies of types to convert */ dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->type, H5T_COPY_TRANSIENT), FALSE); if(dst_id < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy/register datatype") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype") src_id = H5I_register(H5I_DATATYPE, H5T_copy(src->type, H5T_COPY_ALL), FALSE); if(src_id < 0) { - H5I_dec_ref(dst_id, FALSE); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy/register datatype") + H5I_dec_ref(dst_id); + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy/register datatype") } /* end if */ /* Allocate a background buffer */ bkg_size = MAX(H5T_get_size(dst->type), H5T_get_size(src->type)); if(H5T_path_bkg(tpath) && NULL == (bkg_buf = H5FL_BLK_CALLOC(type_conv, bkg_size))) { - H5I_dec_ref(src_id, FALSE); - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(src_id); + H5I_dec_ref(dst_id); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") } /* end if */ /* Convert fill value */ if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, dst->buf, bkg_buf, H5AC_ind_dxpl_id) < 0) { - H5I_dec_ref(src_id, FALSE); - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(src_id); + H5I_dec_ref(dst_id); if(bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); - HGOTO_ERROR(H5E_DATASET, H5E_CANTCONVERT, NULL, "datatype conversion failed") + HGOTO_ERROR(H5E_OHDR, H5E_CANTCONVERT, NULL, "datatype conversion failed") } /* end if */ /* Release the background buffer */ - H5I_dec_ref(src_id, FALSE); - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(src_id); + H5I_dec_ref(dst_id); if(bkg_buf) bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf); } /* end if */ @@ -695,20 +695,20 @@ H5O_fill_reset_dyn(H5O_fill_t *fill) /* Copy the fill value datatype and get an ID for it */ if(NULL == (fill_type = H5T_copy(fill->type, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy fill value datatype") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy fill value datatype") if((fill_type_id = H5I_register(H5I_DATATYPE, fill_type, FALSE)) < 0) { H5T_close(fill_type); - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register fill value datatype") + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to register fill value datatype") } /* end if */ /* Create a scalar dataspace for the fill value element */ if(NULL == (fill_space = H5S_create(H5S_SCALAR))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create scalar dataspace") + HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create scalar dataspace") /* Reclaim any variable length components of the fill value */ if(H5D_vlen_reclaim(fill_type_id, fill_space, H5P_DATASET_XFER_DEFAULT, fill->buf) < 0) { H5S_close(fill_space); - HGOTO_ERROR(H5E_DATASET, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data") + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "unable to reclaim variable-length fill value data") } /* end if */ /* Release the scalar fill value dataspace */ @@ -725,8 +725,9 @@ H5O_fill_reset_dyn(H5O_fill_t *fill) } /* end if */ done: - if(fill_type_id > 0) - H5I_dec_ref(fill_type_id, FALSE); + if(fill_type_id > 0 && H5I_dec_ref(fill_type_id) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_fill_reset_dyn() */ @@ -934,13 +935,13 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_ * Can we convert between source and destination data types? */ if(NULL == (tpath = H5T_path_find(fill->type, dset_type, NULL, NULL, dxpl_id, FALSE))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") /* Don't bother doing anything if there will be no actual conversion */ if(!H5T_path_noop(tpath)) { if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill->type, H5T_COPY_ALL), FALSE)) < 0 || (dst_id = H5I_register(H5I_DATATYPE, H5T_copy(dset_type, H5T_COPY_ALL), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy/register data type") /* * Datatype conversions are always done in place, so we need a buffer @@ -961,7 +962,7 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_ /* Do the conversion */ if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "datatype conversion failed") /* Update the fill message */ if(buf != fill->buf) { @@ -978,10 +979,10 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_ } /* end if */ done: - if(src_id >= 0) - H5I_dec_ref(src_id, FALSE); - if(dst_id >= 0) - H5I_dec_ref(dst_id, FALSE); + if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") + if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "unable to decrement ref count for temp ID") if(buf != fill->buf) H5MM_xfree(buf); if(bkg) diff --git a/src/H5Olink.c b/src/H5Olink.c index 0438bb7..7e14558 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -629,7 +629,7 @@ H5O_link_delete(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh, void *_mesg) /* Get the link class for this type of link. */ if(NULL == (link_class = H5L_find_class(lnk->type))) - HGOTO_ERROR(H5E_LINK, H5E_NOTREGISTERED, FAIL, "link class not registered") + HGOTO_ERROR(H5E_OHDR, H5E_NOTREGISTERED, FAIL, "link class not registered") /* Check for delete callback */ if(link_class->del_func) { @@ -641,12 +641,12 @@ H5O_link_delete(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh, void *_mesg) /* Call user-defined link's 'delete' callback */ if((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) { - H5I_dec_ref(file_id, FALSE); + H5I_dec_ref(file_id); HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "link deletion callback returned failure") } /* end if */ /* Release the file ID */ - if(H5I_dec_ref(file_id, FALSE) < 0) + if(H5I_dec_ref(file_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") } /* end if */ } /* end if */ @@ -1379,21 +1379,21 @@ done: herr_t H5Pclose(hid_t plist_id) { - herr_t ret_value=SUCCEED; /* return value */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Pclose, FAIL); H5TRACE1("e", "i", plist_id); - if(plist_id==H5P_DEFAULT) - HGOTO_DONE(SUCCEED); - - /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(plist_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); + /* Allow default property lists to pass through without throwing an error */ + if(H5P_DEFAULT != plist_id) { + /* Check arguments. */ + if(H5I_GENPROP_LST != H5I_get_type(plist_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - /* Close the property list */ - if(H5I_dec_ref(plist_id, TRUE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close"); + /* Close the property list */ + if(H5I_dec_app_ref(plist_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close") + } /* end if */ done: FUNC_LEAVE_API(ret_value); @@ -1522,13 +1522,13 @@ H5Pclose_class(hid_t cls_id) /* Check arguments */ if(H5I_GENPROP_CLS != H5I_get_type(cls_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class") /* Close the property list class */ - if(H5I_dec_ref(cls_id, TRUE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close"); + if(H5I_dec_app_ref(cls_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close") done: - FUNC_LEAVE_API(ret_value); + FUNC_LEAVE_API(ret_value) } /* H5Pclose_class() */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 4055664..97b492d 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -1682,9 +1682,9 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/, * Can we convert between the source and destination datatypes? */ if(NULL == (tpath = H5T_path_find(fill.type, type, NULL, NULL, dxpl_id, FALSE))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to convert between src and dst datatypes") if((src_id = H5I_register(H5I_DATATYPE, H5T_copy(fill.type, H5T_COPY_TRANSIENT), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype") + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype") /* * Data type conversions are always done in place, so we need a buffer @@ -1694,11 +1694,11 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/, if(H5T_get_size(type) >= H5T_get_size(fill.type)) { buf = value; if(H5T_path_bkg(tpath) && NULL == (bkg = H5MM_malloc(H5T_get_size(type)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") } /* end if */ else { if(NULL == (buf = H5MM_malloc(H5T_get_size(fill.type)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion") + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "memory allocation failed for type conversion") if(H5T_path_bkg(tpath)) bkg = value; } /* end else */ @@ -1706,9 +1706,9 @@ H5P_get_fill_value(H5P_genplist_t *plist, const H5T_t *type, void *value/*out*/, /* Do the conversion */ if((dst_id = H5I_register(H5I_DATATYPE, H5T_copy(type, H5T_COPY_TRANSIENT), FALSE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register datatype") + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy/register datatype") if(H5T_convert(tpath, src_id, dst_id, (size_t)1, (size_t)0, (size_t)0, buf, bkg, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed") + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "datatype conversion failed") if(buf != value) HDmemcpy(value, buf, H5T_get_size(type)); @@ -1717,10 +1717,10 @@ done: H5MM_xfree(buf); if(bkg != value) H5MM_xfree(bkg); - if(src_id >= 0) - H5I_dec_ref(src_id, FALSE); - if(dst_id >= 0) - H5I_dec_ref(dst_id, FALSE); + if(src_id >= 0 && H5I_dec_ref(src_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") + if(dst_id >= 0 && H5I_dec_ref(dst_id) < 0) + HDONE_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_get_fill_value() */ diff --git a/src/H5Plapl.c b/src/H5Plapl.c index 22cef28..438a297 100644 --- a/src/H5Plapl.c +++ b/src/H5Plapl.c @@ -208,8 +208,8 @@ H5P_lacc_elink_fapl_del(hid_t UNUSED prop_id, const char UNUSED *name, size_t UN l_fapl_id = (*(const hid_t *)value); - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") + if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) @@ -282,8 +282,8 @@ H5P_lacc_elink_fapl_close(const char UNUSED *name, size_t UNUSED size, void *val HDassert(value); l_fapl_id = (*(const hid_t *)value); - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") + if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") done: FUNC_LEAVE_NOAPI(ret_value) @@ -589,15 +589,15 @@ H5Pset_elink_fapl(hid_t lapl_id, hid_t fapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl") /* Close the current file access property list if set */ - if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE) < 0)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") + if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id) < 0)) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") if(NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access property list"); /* Make a copy of the property list for FAPL_ID */ if((new_fapl_id = H5P_copy_plist(fapl_plist, FALSE)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file access properties") + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file access properties") /* Set the file access property list for the link access */ if(H5P_set(plist, H5L_ACS_ELINK_FAPL_NAME, &new_fapl_id) < 0) @@ -891,9 +891,8 @@ 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, FALSE) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEFILE, FAIL, "can't determine name") + if(file_id > 0 && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "can't decrement ref count of temp ID") FUNC_LEAVE_NOAPI(ret_value) } /* end H5R_get_name() */ @@ -355,7 +355,7 @@ done: herr_t H5Sclose(hid_t space_id) { - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(H5Sclose, FAIL) H5TRACE1("e", "i", space_id); @@ -365,12 +365,12 @@ H5Sclose(hid_t space_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") /* When the reference count reaches zero the resources are freed */ - if (H5I_dec_ref(space_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") + if(H5I_dec_app_ref(space_id) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sclose() */ /*------------------------------------------------------------------------- @@ -1719,11 +1719,11 @@ H5Tclose(hid_t type_id) /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_IMMUTABLE==dt->shared->state) + if(H5T_STATE_IMMUTABLE == dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") /* When the reference count reaches zero the resources are freed */ - if(H5I_dec_ref(type_id, TRUE) < 0) + if(H5I_dec_app_ref(type_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") done: @@ -2341,28 +2341,28 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, old_path->dst->shared->type!=dst->shared->type) { continue; } - if ((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE))<0 || - (tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE))<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query"); + if((tmp_sid = H5I_register(H5I_DATATYPE, H5T_copy(old_path->src, H5T_COPY_ALL), FALSE)) < 0 || + (tmp_did = H5I_register(H5I_DATATYPE, H5T_copy(old_path->dst, H5T_COPY_ALL), FALSE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data types for conv query") HDmemset(&cdata, 0, sizeof cdata); cdata.command = H5T_CONV_INIT; - if ((func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, - NULL, NULL, dxpl_id)<0) { - H5I_dec_ref(tmp_sid, FALSE); - H5I_dec_ref(tmp_did, FALSE); + if((func)(tmp_sid, tmp_did, &cdata, (size_t)0, (size_t)0, (size_t)0, + NULL, NULL, dxpl_id) < 0) { + H5I_dec_ref(tmp_sid); + H5I_dec_ref(tmp_did); tmp_sid = tmp_did = -1; H5E_clear_stack(NULL); continue; } /* end if */ /* Create a new conversion path */ - if (NULL==(new_path=H5FL_CALLOC(H5T_path_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); + if(NULL == (new_path = H5FL_CALLOC(H5T_path_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDstrncpy(new_path->name, name, (size_t)H5T_NAMELEN); new_path->name[H5T_NAMELEN-1] = '\0'; - if (NULL==(new_path->src=H5T_copy(old_path->src, H5T_COPY_ALL)) || - NULL==(new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types"); + if(NULL == (new_path->src = H5T_copy(old_path->src, H5T_COPY_ALL)) || + NULL == (new_path->dst=H5T_copy(old_path->dst, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data types") new_path->func = func; new_path->is_hard = FALSE; new_path->cdata = cdata; @@ -2389,8 +2389,8 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst, old_path = H5FL_FREE(H5T_path_t, old_path); /* Release temporary atoms */ - H5I_dec_ref(tmp_sid, FALSE); - H5I_dec_ref(tmp_did, FALSE); + H5I_dec_ref(tmp_sid); + H5I_dec_ref(tmp_did); tmp_sid = tmp_did = -1; /* We don't care about any failures during the freeing process */ @@ -2408,9 +2408,9 @@ done: new_path = H5FL_FREE(H5T_path_t, new_path); } /* end if */ if(tmp_sid >= 0) - H5I_dec_ref(tmp_sid, FALSE); + H5I_dec_ref(tmp_sid); if(tmp_did >= 0) - H5I_dec_ref(tmp_did, FALSE); + H5I_dec_ref(tmp_did); } /* end if */ FUNC_LEAVE_NOAPI(ret_value); @@ -4409,9 +4409,9 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, if((func)(src_id, dst_id, &(path->cdata), (size_t)0, (size_t)0, (size_t)0, NULL, NULL, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function") if(src_id >= 0) - H5I_dec_ref(src_id, FALSE); + H5I_dec_ref(src_id); if(dst_id >= 0) - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(dst_id); src_id = dst_id = -1; path->func = func; path->is_hard = TRUE; @@ -4441,8 +4441,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name, path->func = H5T_g.soft[i].func; path->is_hard = FALSE; } /* end else */ - H5I_dec_ref(src_id, FALSE); - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(src_id); + H5I_dec_ref(dst_id); src_id = dst_id = -1; } /* end for */ if(!path->func) @@ -4529,9 +4529,9 @@ done: path = H5FL_FREE(H5T_path_t, path); } /* end if */ if(src_id >= 0) - H5I_dec_ref(src_id, FALSE); + H5I_dec_ref(src_id); if(dst_id >= 0) - H5I_dec_ref(dst_id, FALSE); + H5I_dec_ref(dst_id); FUNC_LEAVE_NOAPI(ret_value); } /* end H5T_path_find() */ @@ -29,16 +29,14 @@ typedef struct H5TS_cancel_struct { } H5TS_cancel_t; /* Global variable definitions */ -pthread_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; -pthread_key_t H5TS_errstk_key_g; -pthread_key_t H5TS_funcstk_key_g; -pthread_key_t H5TS_cancel_key_g; -hbool_t H5TS_allow_concurrent_g = FALSE; /* concurrent APIs override this */ - -/* Local function definitions */ -#ifdef NOT_USED -static void H5TS_mutex_init(H5TS_mutex_t *mutex); -#endif /* NOT_USED */ +#ifdef H5_HAVE_WIN_THREADS +H5TS_once_t H5TS_first_init_g; +#else /* H5_HAVE_WIN_THREADS */ +H5TS_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; +#endif /* H5_HAVE_WIN_THREADS */ +H5TS_key_t H5TS_errstk_key_g; +H5TS_key_t H5TS_funcstk_key_g; +H5TS_key_t H5TS_cancel_key_g; /*-------------------------------------------------------------------------- @@ -70,12 +68,45 @@ H5TS_key_destructor(void *key_val) HDfree(key_val); } +#ifdef H5_HAVE_WIN_THREADS + /*-------------------------------------------------------------------------- * NAME - * H5TS_first_thread_init + * H5TS_win32_first_thread_init * * USAGE - * H5TS_first_thread_init() + * H5TS_win32_first_thread_init() + * + * RETURNS + * + * DESCRIPTION + * Special function on windows needed to call the H5TS_first_thread_init + * function. + * + * PROGRAMMER: Mike McGreevy + * September 1, 2010 + * + * MODIFICATIONS: + * + *-------------------------------------------------------------------------- + */ +BOOL CALLBACK +H5TS_win32_first_thread_init(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) +{ + InitializeCriticalSection ( &H5_g.init_lock.CriticalSection ); + H5TS_errstk_key_g = TlsAlloc(); + H5TS_funcstk_key_g = TlsAlloc(); + H5TS_cancel_key_g = TlsAlloc(); + + return TRUE; +} /* H5TS_win32_first_thread_init() */ +#else /* H5_HAVE_WIN_THREADS */ +/*-------------------------------------------------------------------------- + * NAME + * H5TS_pthread_first_thread_init + * + * USAGE + * H5TS_pthread_first_thread_init() * * RETURNS * @@ -92,7 +123,7 @@ H5TS_key_destructor(void *key_val) *-------------------------------------------------------------------------- */ void -H5TS_first_thread_init(void) +H5TS_pthread_first_thread_init(void) { H5_g.H5_libinit_g = FALSE; @@ -110,6 +141,7 @@ H5TS_first_thread_init(void) /* initialize key for thread cancellability mechanism */ pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor); } +#endif /* H5_HAVE_WIN_THREADS */ /*-------------------------------------------------------------------------- * NAME @@ -139,9 +171,11 @@ H5TS_first_thread_init(void) herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex) { - herr_t ret_value; - - ret_value = pthread_mutex_lock(&mutex->atomic_lock); +#ifdef H5_HAVE_WIN_THREADS + EnterCriticalSection( &mutex->CriticalSection); + return 0; +#else /* H5_HAVE_WIN_THREADS */ + herr_t ret_value = pthread_mutex_lock(&mutex->atomic_lock); if (ret_value) return ret_value; @@ -159,7 +193,8 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) mutex->lock_count = 1; } - return pthread_mutex_unlock(&mutex->atomic_lock); + return pthread_mutex_unlock(&mutex->atomic_lock); +#endif /* H5_HAVE_WIN_THREADS */ } /*-------------------------------------------------------------------------- @@ -191,9 +226,12 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex) { - herr_t ret_value; /* Return value */ - - ret_value = pthread_mutex_lock(&mutex->atomic_lock); +#ifdef H5_HAVE_WIN_THREADS + /* Releases ownership of the specified critical section object. */ + LeaveCriticalSection(&mutex->CriticalSection); + return 0; +#else /* H5_HAVE_WIN_THREADS */ + herr_t ret_value = pthread_mutex_lock(&mutex->atomic_lock); if(ret_value) return ret_value; @@ -210,8 +248,9 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) ret_value = err; } /* end if */ - return ret_value; -} + return ret_value; +#endif /* H5_HAVE_WIN_THREADS */ +} /* H5TS_mutex_unlock */ /*-------------------------------------------------------------------------- * NAME @@ -246,17 +285,21 @@ H5TS_mutex_unlock(H5TS_mutex_t *mutex) herr_t H5TS_cancel_count_inc(void) { +#ifdef H5_HAVE_WIN_THREADS + /* unsupported; just return 0 */ + return SUCCEED; +#else /* H5_HAVE_WIN_THREADS */ H5TS_cancel_t *cancel_counter; - herr_t ret_value = 0; + herr_t ret_value = SUCCEED; - cancel_counter = pthread_getspecific(H5TS_cancel_key_g); + cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_g); if (!cancel_counter) { /* * First time thread calls library - create new counter and associate * with key */ - cancel_counter = H5MM_calloc(sizeof(H5TS_cancel_t)); + cancel_counter = (H5TS_cancel_t *)H5MM_calloc(sizeof(H5TS_cancel_t)); if (!cancel_counter) { H5E_push_stack(NULL, "H5TS_cancel_count_inc", @@ -274,7 +317,9 @@ H5TS_cancel_count_inc(void) &cancel_counter->previous_state); ++cancel_counter->cancel_count; - return ret_value; + + return ret_value; +#endif /* H5_HAVE_WIN_THREADS */ } /*-------------------------------------------------------------------------- @@ -307,16 +352,57 @@ H5TS_cancel_count_inc(void) herr_t H5TS_cancel_count_dec(void) { - herr_t ret_value = 0; - register H5TS_cancel_t *cancel_counter; +#ifdef H5_HAVE_WIN_THREADS + /* unsupported; will just return 0 */ + return SUCCEED; +#else /* H5_HAVE_WIN_THREADS */ + register H5TS_cancel_t *cancel_counter; + herr_t ret_value = SUCCEED; - cancel_counter = pthread_getspecific(H5TS_cancel_key_g); + cancel_counter = (H5TS_cancel_t *)H5TS_get_thread_local_value(H5TS_cancel_key_g); if (cancel_counter->cancel_count == 1) ret_value = pthread_setcancelstate(cancel_counter->previous_state, NULL); - --cancel_counter->cancel_count; + --cancel_counter->cancel_count; + return ret_value; +#endif /* H5_HAVE_WIN_THREADS */ } + +/*-------------------------------------------------------------------------- + * NAME + * H5TS_create_thread + * + * RETURNS + * Thread identifier. + * + * DESCRIPTION + * Spawn off a new thread calling function 'func' with input 'udata'. + * + * PROGRAMMER: Mike McGreevy + * August 31, 2010 + * + *-------------------------------------------------------------------------- + */ +H5TS_thread_t +H5TS_create_thread(void * func, H5TS_attr_t * attr, void*udata) +{ + H5TS_thread_t ret_value; + +#ifdef H5_HAVE_WIN_THREADS + + ret_value = CreateThread(NULL, 0, func, udata, 0, NULL); + +#else /* H5_HAVE_WIN_THREADS */ + + pthread_create(&ret_value, attr, (void * (*)(void *))func, udata); + +#endif /* H5_HAVE_WIN_THREADS */ + + return ret_value; + +} /* H5TS_create_thread */ + #endif /* H5_HAVE_THREADSAFE */ diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index 0d0b620..7f55f4f 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -33,30 +33,91 @@ #include "H5TSpublic.h" /*Public API prototypes */ #endif /* LATER */ +#ifdef H5_HAVE_WIN_THREADS + /* Library level data structures */ +/* Mutexes, Threads, and Attributes */ +typedef struct H5TS_mutex_struct { + CRITICAL_SECTION CriticalSection; +} H5TS_mutex_t; +typedef CRITICAL_SECTION H5TS_mutex_simple_t; +typedef HANDLE H5TS_thread_t; +typedef HANDLE H5TS_attr_t; +typedef DWORD H5TS_key_t; +typedef INIT_ONCE H5TS_once_t; + +/* Defines */ +/* not used on windows side, but need to be defined to something */ +#define H5TS_SCOPE_SYSTEM 0 +#define H5TS_SCOPE_PROCESS 0 + +/* Functions */ +#define H5TS_get_thread_local_value(key) TlsGetValue( key ) +#define H5TS_set_thread_local_value(key, value) TlsSetValue( key, value ) +#define H5TS_attr_init(attr_ptr) 0 +#define H5TS_attr_setscope(attr_ptr, scope) 0 +#define H5TS_attr_destroy(attr_ptr) 0 +#define H5TS_wait_for_thread(thread) WaitForSingleObject(thread, INFINITE) +#define H5TS_mutex_init(mutex) InitializeCriticalSection(mutex) +#define H5TS_mutex_lock_simple(mutex) EnterCriticalSection(mutex) +#define H5TS_mutex_unlock_simple(mutex) LeaveCriticalSection(mutex) + +H5_DLL BOOL CALLBACK +H5TS_win32_first_thread_init(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex); + +#else /* H5_HAVE_WIN_THREADS */ + +/* Library level data structures */ + +/* Mutexes, Threads, and Attributes */ typedef struct H5TS_mutex_struct { pthread_t owner_thread; /* current lock owner */ pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ pthread_cond_t cond_var; /* condition variable */ unsigned int lock_count; } H5TS_mutex_t; +typedef pthread_t H5TS_thread_t; +typedef pthread_attr_t H5TS_attr_t; +typedef pthread_mutex_t H5TS_mutex_simple_t; +typedef pthread_key_t H5TS_key_t; +typedef pthread_once_t H5TS_once_t; + +/* Scope Definitions */ +#define H5TS_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM +#define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS + +/* Functions */ +#define H5TS_get_thread_local_value(key) pthread_getspecific( key ) +#define H5TS_set_thread_local_value(key, value) pthread_setspecific( key, value ) +#define H5TS_attr_init(attr_ptr) pthread_attr_init((attr_ptr)) +#define H5TS_attr_setscope(attr_ptr, scope) pthread_attr_setscope(attr_ptr, scope) +#define H5TS_attr_destroy(attr_ptr) pthread_attr_destroy(attr_ptr) +#define H5TS_wait_for_thread(thread) pthread_join(thread, NULL) +#define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL) +#define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) +#define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) -/* Extern global variables */ -extern pthread_once_t H5TS_first_init_g; -extern pthread_key_t H5TS_errstk_key_g; -extern pthread_key_t H5TS_funcstk_key_g; +#endif /* H5_HAVE_WIN_THREADS */ + +/* External global variables */ +extern H5TS_once_t H5TS_first_init_g; +extern H5TS_key_t H5TS_errstk_key_g; +extern H5TS_key_t H5TS_funcstk_key_g; #if defined c_plusplus || defined __cplusplus extern "C" { #endif /* c_plusplus || __cplusplus */ -H5_DLL void H5TS_first_thread_init(void); +H5_DLL void H5TS_pthread_first_thread_init(void); H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); H5_DLL herr_t H5TS_cancel_count_inc(void); H5_DLL herr_t H5TS_cancel_count_dec(void); +H5_DLL H5TS_thread_t H5TS_create_thread(void * func, H5TS_attr_t * attr, void *udata); + + #if defined c_plusplus || defined __cplusplus } diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index c7f0259..b924b61 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -664,7 +664,8 @@ H5Tget_create_plist(hid_t dtype_id) done: if(ret_value < 0) if(new_tcpl_id > 0) - (void)H5I_dec_ref(new_tcpl_id, TRUE); + if(H5I_dec_app_ref(new_tcpl_id) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to close temporary object") FUNC_LEAVE_API(ret_value) } /* end H5Tget_create_plist() */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 6069577..9d98e50 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1783,9 +1783,9 @@ H5T_conv_struct_free(H5T_conv_struct_t *priv) for (i=0; i<priv->src_nmembs; i++) if (src2dst[i] >= 0) { - status = H5I_dec_ref(src_memb_id[i], FALSE); + status = H5I_dec_ref(src_memb_id[i]); HDassert(status >= 0); - status = H5I_dec_ref(dst_memb_id[src2dst[i]], FALSE); + status = H5I_dec_ref(dst_memb_id[src2dst[i]]); HDassert(status >= 0); } @@ -3173,9 +3173,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Release the temporary datatype IDs used */ if(tsrc_id >= 0) - H5I_dec_ref(tsrc_id, FALSE); + H5I_dec_ref(tsrc_id); if(tdst_id >= 0) - H5I_dec_ref(tdst_id, FALSE); + H5I_dec_ref(tdst_id); break; default: /* Some other command we don't know about yet.*/ @@ -3325,9 +3325,9 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* Release the temporary datatype IDs used */ if(tsrc_id >= 0) - H5I_dec_ref(tsrc_id, FALSE); + H5I_dec_ref(tsrc_id); if(tdst_id >= 0) - H5I_dec_ref(tdst_id, FALSE); + H5I_dec_ref(tdst_id); break; default: /* Some other command we don't know about yet.*/ @@ -637,7 +637,7 @@ H5Z_prepare_prelude_callback_dcpl(hid_t dcpl_id, hid_t type_id, H5Z_prelude_type } /* end if */ done: - if(space_id > 0 && H5I_dec_ref(space_id, FALSE) < 0) + if(space_id > 0 && H5I_dec_ref(space_id) < 0) HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5private.h b/src/H5private.h index 3875fb3..d506a59 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -30,8 +30,12 @@ /* include the pthread header */ #ifdef H5_HAVE_THREADSAFE +#ifdef H5_HAVE_PTHREAD_H #include <pthread.h> -#endif +#else /* H5_HAVE_PTHREAD_H */ +#define H5_HAVE_WIN_THREADS +#endif /* H5_HAVE_PTHREAD_H */ +#endif /* H5_HAVE_THREADSAFE */ /* * Include ANSI-C header files. @@ -1666,8 +1670,11 @@ typedef struct H5_api_struct { #define H5_INIT_GLOBAL H5_g.H5_libinit_g /* Macro for first thread initialization */ -#define H5_FIRST_THREAD_INIT \ - pthread_once(&H5TS_first_init_g, H5TS_first_thread_init); +#ifdef H5_HAVE_WIN_THREADS +#define H5_FIRST_THREAD_INIT InitOnceExecuteOnce(&H5TS_first_init_g, H5TS_win32_first_thread_init, NULL, NULL); +#else +#define H5_FIRST_THREAD_INIT pthread_once(&H5TS_first_init_g, H5TS_pthread_first_thread_init); +#endif /* Macros for threadsafe HDF-5 Phase I locks */ #define H5_API_LOCK \ diff --git a/src/H5public.h b/src/H5public.h index 361906a..c92e628 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -43,9 +43,13 @@ # include <limits.h> /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */ #endif #ifndef __cplusplus -#ifdef H5_HAVE_STDINT_H +# ifdef H5_HAVE_STDINT_H # include <stdint.h> /*for C9x types */ -#endif +# endif +#else +# ifdef H5_HAVE_STDINT_H_CXX +# include <stdint.h> /*for C9x types when include from C++ */ +# endif #endif #ifdef H5_HAVE_INTTYPES_H # include <inttypes.h> /* For uint64_t on some platforms */ diff --git a/src/Makefile.in b/src/Makefile.in index 8dbba32..fddf135 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -385,7 +385,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -434,6 +433,7 @@ H5CC_PP = $(bindir)/h5pcc H5FC = $(bindir)/h5fc H5FC_PP = $(bindir)/h5pfc H5CPP = $(bindir)/h5c++ +ACLOCAL_AMFLAGS = "-I m4" # The trace script; this is used on source files from the C library to # insert tracing macros. |