[svn-r19363] When mandatory filter failed to write data chunks, the dataset

couldn't close (bug 1260).  The fix releases all resources and closes
the dataset but returns a failure.

Tested with h5committest - jam, heiwa, amani.
This commit is contained in:
Raymond Lu 2010-09-09 13:15:36 -05:00
parent bed1276413
commit 073eb187d6
41 changed files with 577 additions and 163 deletions

View File

@ -838,6 +838,7 @@
./test/freespace.c
./test/fill_old.h5
./test/fillval.c
./test/filter_fail.c
./test/flush1.c
./test/flush2.c
./test/gen_bad_ohdr.c _DO_NOT_DISTRIBUTE_

2
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in 19185 2010-08-06 19:32:23Z acheng .
# From configure.in Id: configure.in 19309 2010-08-26 17:16:50Z koziol .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65 for HDF5 1.9.75.
#

View File

@ -76,6 +76,9 @@ New Features
Library:
--------
- When a mandatory filter failed to write data chunks, the dataset
couldn't close (bug 1260). The fix releases all resources and closes
the dataset but returns a failure. (SLU - 2010/9/8)
- H5Tset_order and H5Tget_order now support all data types. A new byte
order H5T_ORDER_MIXED has been added specifically for compound datatype
and its derived type. Please see bug #1934. (SLU - 2010/8/23)

View File

@ -1030,9 +1030,9 @@ 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);
(void)H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
(void)H5I_dec_ref(dst_id, FALSE);
(void)H5I_dec_ref(dst_id, FALSE, FALSE);
if(tconv_buf && !tconv_owned)
tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf);
if(bkg_buf)
@ -1176,9 +1176,9 @@ 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);
(void)H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
(void)H5I_dec_ref(dst_id, FALSE);
(void)H5I_dec_ref(dst_id, FALSE, FALSE);
if(tconv_buf)
tconv_buf = H5FL_BLK_FREE(attr_buf, tconv_buf);
if(bkg_buf)
@ -2047,7 +2047,7 @@ 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)
if(H5I_dec_ref(obj_loc_id, TRUE, FALSE) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close temporary object")
} /* end if */
else if(loc_found && H5G_loc_free(&obj_loc) < 0)
@ -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_ref(attr_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute")
done:

View File

@ -385,9 +385,9 @@ H5AC_term_interface(void)
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, FALSE, FALSE) < 0 ||
H5I_dec_ref(H5AC_noblock_dxpl_id, FALSE, FALSE) < 0 ||
H5I_dec_ref(H5AC_ind_dxpl_id, FALSE, FALSE) < 0)
H5E_clear_stack(NULL); /*ignore error*/
else {
/* Reset static IDs */

View File

@ -1029,7 +1029,7 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si
done:
if(buf_sid > 0)
if(H5I_dec_ref(buf_sid, FALSE) < 0)
if(H5I_dec_ref(buf_sid, FALSE, FALSE) < 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 */
@ -1041,7 +1041,7 @@ done:
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, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, NULL, "Can't decrement temporary datatype ID")
if(buf)
buf = H5FL_BLK_FREE(attr_buf, buf);

View File

@ -378,9 +378,13 @@ 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)
if(H5I_dec_ref(dset_id, TRUE, TRUE) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free")
done:
@ -604,30 +608,30 @@ 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, FALSE, FALSE);
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, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
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, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
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);
H5I_dec_ref(src_id, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
if(bkg_buf)
bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
} /* end if */
@ -643,7 +647,7 @@ 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);
(void)H5I_dec_ref(new_dcpl_id, TRUE, FALSE);
FUNC_LEAVE_API(ret_value)
} /* end H5Dget_create_plist() */
@ -722,7 +726,7 @@ 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);
(void)H5I_dec_ref(new_dapl_id, TRUE, FALSE);
FUNC_LEAVE_API(ret_value)
} /* end H5Dget_access_plist() */
@ -1029,11 +1033,11 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id,
done:
if(vlen_bufsize.fspace_id > 0) {
if(H5I_dec_ref(vlen_bufsize.fspace_id, FALSE) < 0)
if(H5I_dec_ref(vlen_bufsize.fspace_id, FALSE, 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)
if(H5I_dec_ref(vlen_bufsize.mspace_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace")
} /* end if */
if(vlen_bufsize.fl_tbuf != NULL)
@ -1041,7 +1045,7 @@ done:
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)
if(H5I_dec_ref(vlen_bufsize.xfer_pid, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement ref count on property list")
} /* end if */

View File

@ -825,7 +825,7 @@ done:
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)
if(H5I_dec_ref(f_tid, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
} /* end if */
if(file_space_normalized) {
@ -2488,7 +2488,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 */
@ -4634,16 +4634,16 @@ 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, FALSE, FALSE) < 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)
if(H5I_dec_ref(tid_src, FALSE, 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)
if(H5I_dec_ref(tid_dst, FALSE, 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)
if(H5I_dec_ref(tid_mem, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(buf)
H5MM_xfree(buf);
@ -4845,8 +4845,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)

View File

@ -558,16 +558,16 @@ 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, FALSE, FALSE) < 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)
if(H5I_dec_ref(tid_src, FALSE, 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)
if(H5I_dec_ref(tid_dst, FALSE, 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)
if(H5I_dec_ref(tid_mem, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(buf)
buf = H5FL_BLK_FREE(type_conv, buf);

View File

@ -1450,16 +1450,16 @@ 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, FALSE, FALSE) < 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)
if(H5I_dec_ref(tid_src, FALSE, 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)
if(H5I_dec_ref(tid_dst, FALSE, 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)
if(H5I_dec_ref(tid_mem, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't decrement temporary datatype ID")
if(buf)
buf = H5FL_BLK_FREE(type_conv, buf);

View File

@ -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, FALSE, FALSE) < 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, FALSE, FALSE) < 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, FALSE, FALSE);
else if(fb_info->mem_type)
H5T_close(fb_info->mem_type);
if(fb_info->bkg_buf)

View File

@ -561,7 +561,7 @@ done:
if(ret_value == NULL)
if(new_dset != NULL) {
if(new_dset->dcpl_id != 0)
(void)H5I_dec_ref(new_dset->dcpl_id, FALSE);
(void)H5I_dec_ref(new_dset->dcpl_id, FALSE, FALSE);
new_dset = H5FL_FREE(H5D_shared_t, new_dset);
} /* end if */
@ -1061,7 +1061,7 @@ done:
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)
if(H5I_dec_ref(new_dset->shared->type_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype")
} /* end if */
if(H5F_addr_defined(new_dset->oloc.addr)) {
@ -1072,7 +1072,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, FALSE, FALSE) < 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 */
@ -1319,7 +1319,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, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype")
} /* end if */
else {
@ -1367,9 +1367,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) {
@ -1403,9 +1403,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:
@ -1426,8 +1427,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, FALSE, FALSE) < 0 || H5S_close(dataset->shared->space) < 0 ||
H5I_dec_ref(dataset->shared->dcpl_id, FALSE, FALSE) < 0);
/* Remove the dataset from the list of opened objects in the file */
if(H5FO_top_decr(dataset->oloc.file, dataset->oloc.addr) < 0)

View File

@ -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_ref(class_id, TRUE, FALSE) < 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_ref(err_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error message")
done:
@ -1036,7 +1036,7 @@ H5Eset_current_stack(hid_t err_stack)
* Decrement the counter on the error stack. It will be freed if the count
* reaches zero.
*/
if(H5I_dec_ref(err_stack, TRUE) < 0)
if(H5I_dec_ref(err_stack, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack")
} /* end if */
@ -1138,7 +1138,7 @@ H5Eclose_stack(hid_t 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_ref(stack_id, TRUE, FALSE)<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack")
} /* end if */

View File

@ -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, FALSE, FALSE) < 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, FALSE, FALSE) < 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, FALSE, FALSE) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error class")
/* Release strings */

View File

@ -1063,7 +1063,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush)
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)
if(H5I_dec_ref(f->shared->fcpl_id, FALSE, FALSE) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list")
@ -1874,7 +1874,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], FALSE, FALSE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object")
} /* end while */
@ -1886,7 +1886,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], FALSE, FALSE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object")
} /* end while */
} /* end if */
@ -1973,7 +1973,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_ref(file_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed")
done:

View File

@ -413,7 +413,7 @@ H5FDunregister(hid_t driver_id)
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)
if(H5I_dec_ref(driver_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to unregister file driver")
done:
@ -660,7 +660,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, FALSE, FALSE) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement reference count for driver")
done:
@ -1187,7 +1187,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, FALSE, FALSE) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
/*

View File

@ -472,7 +472,7 @@ H5FD_family_fapl_free(void *_fa)
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, FALSE, FALSE)<0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
H5MM_xfree(fa);
@ -558,7 +558,7 @@ H5FD_family_dxpl_free(void *_dx)
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, FALSE, FALSE)<0)
HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
H5MM_xfree(dx);
@ -870,7 +870,7 @@ done:
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, FALSE, FALSE)<0)
HDONE_ERROR(H5E_VFL, H5E_CANTDEC, NULL, "can't close driver ID")
if (file->name)
H5MM_xfree(file->name);
@ -921,7 +921,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, FALSE, FALSE) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID")
H5MM_xfree(file->memb);

View File

@ -504,7 +504,7 @@ 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);
(void)H5I_dec_ref(new_gcpl_id, TRUE, FALSE);
} /* end if */
FUNC_LEAVE_API(ret_value)
@ -714,7 +714,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_ref(group_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
done:
@ -1536,7 +1536,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_ref(gid, TRUE, FALSE) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
} /* end if */
else if(grp && H5G_close(grp) < 0)
@ -1869,7 +1869,7 @@ done:
/* Release the group opened */
if(gid > 0) {
if(H5I_dec_ref(gid, TRUE) < 0)
if(H5I_dec_ref(gid, TRUE, FALSE) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
} /* end if */
else if(grp && H5G_close(grp) < 0)

View File

@ -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, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list")
if(ret_value < 0)

View File

@ -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, FALSE, FALSE);
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, FALSE, FALSE) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name")
/* Indicate that the name is _not_ cached, if requested */

View File

@ -270,22 +270,22 @@ 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, FALSE, FALSE) < 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)
if(H5I_dec_ref(cur_grp, FALSE, FALSE) < 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)
if(H5I_dec_ref(cb_return, FALSE, FALSE) < 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, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close copied link access property list")
FUNC_LEAVE_NOAPI(ret_value)

View File

@ -1330,7 +1330,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_ref(id, TRUE, FALSE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count")
done:
@ -1369,20 +1369,25 @@ done:
* 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
* Raymond Lu, 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.
* 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.
*
* Raymond Lu, 7 September 2010
* I added the 3rd parameter to indicate whether H5Dclose is calling
* this function. All other calls should pass in FALSE. Please see
* the comments in the code below.
*
*-------------------------------------------------------------------------
*/
int
H5I_dec_ref(hid_t id, hbool_t app_ref)
H5I_dec_ref(hid_t id, hbool_t app_ref, hbool_t dset_close)
{
H5I_type_t type; /*type the object is in*/
H5I_id_type_t *type_ptr; /*ptr to the type */
@ -1415,6 +1420,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 a dataset is closing, we remove the ID even though the freeing
* might fail. This can happen when a mandatory filter fails to write
* when the dataset is closed and the chunk cache is flushed to the
* file. We have a close the dataset anyway. (SLU - 2010/9/7)
*/
if(1 == id_ptr->count) {
/* (Casting away const OK -QAK) */
@ -1422,8 +1432,11 @@ H5I_dec_ref(hid_t id, hbool_t app_ref)
H5I_remove(id);
ret_value = 0;
} /* end if */
else
else {
if(dset_close)
H5I_remove(id);
ret_value = FAIL;
}
} /* end if */
else {
--(id_ptr->count);

View File

@ -65,7 +65,7 @@ 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, hbool_t app_ref, hbool_t dset_close);
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);

View File

@ -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_ref(grp_id, TRUE, FALSE) < 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_ref(grp_id, TRUE, FALSE) < 0)
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom from UD callback")
} /* end if */
else if(grp != NULL) {

View File

@ -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, FALSE, FALSE) < 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, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for external object")
} /* end if */

View File

@ -1058,7 +1058,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_ref(object_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
break;
@ -3337,7 +3337,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_ref(obj_id, TRUE, FALSE) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
} /* end if */
else if(loc_found && H5G_loc_free(&obj_loc) < 0)

View File

@ -539,30 +539,30 @@ H5O_fill_copy(const void *_src, void *_dst)
HGOTO_ERROR(H5E_DATATYPE, 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);
H5I_dec_ref(dst_id, FALSE, FALSE);
HGOTO_ERROR(H5E_DATATYPE, 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, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
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, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
if(bkg_buf)
bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
HGOTO_ERROR(H5E_DATASET, 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, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
if(bkg_buf)
bkg_buf = H5FL_BLK_FREE(type_conv, bkg_buf);
} /* end if */
@ -726,7 +726,7 @@ H5O_fill_reset_dyn(H5O_fill_t *fill)
done:
if(fill_type_id > 0)
H5I_dec_ref(fill_type_id, FALSE);
H5I_dec_ref(fill_type_id, FALSE, FALSE);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_fill_reset_dyn() */
@ -979,9 +979,9 @@ H5O_fill_convert(H5O_fill_t *fill, H5T_t *dset_type, hbool_t *fill_changed, hid_
done:
if(src_id >= 0)
H5I_dec_ref(src_id, FALSE);
H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
if(buf != fill->buf)
H5MM_xfree(buf);
if(bkg)

View File

@ -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, FALSE, FALSE);
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, FALSE, FALSE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file")
} /* end if */
} /* end if */

View File

@ -1392,7 +1392,7 @@ H5Pclose(hid_t 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)
if(H5I_dec_ref(plist_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close");
done:
@ -1525,7 +1525,7 @@ H5Pclose_class(hid_t cls_id)
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)
if(H5I_dec_ref(cls_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close");
done:

View File

@ -1579,9 +1579,9 @@ done:
if(bkg != value)
H5MM_xfree(bkg);
if(src_id >= 0)
H5I_dec_ref(src_id, FALSE);
H5I_dec_ref(src_id, FALSE, FALSE);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_get_fill_value() */

View File

@ -208,7 +208,7 @@ 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))
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE, FALSE) < 0))
HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
done:
@ -282,7 +282,7 @@ 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))
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE, FALSE) < 0))
HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
done:
@ -589,7 +589,7 @@ 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))
if((l_fapl_id > H5P_DEFAULT) && (H5I_dec_ref(l_fapl_id, FALSE, FALSE) < 0))
HGOTO_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list")
if(NULL == (fapl_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS)))

View File

@ -892,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, FALSE) < 0)
if(H5I_dec_ref(file_id, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_REFERENCE, H5E_CANTCLOSEFILE, FAIL, "can't determine name")
FUNC_LEAVE_NOAPI(ret_value)

View File

@ -365,7 +365,7 @@ 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)
if (H5I_dec_ref(space_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id")
done:

View File

@ -1723,7 +1723,7 @@ H5Tclose(hid_t type_id)
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_ref(type_id, TRUE, FALSE) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id")
done:
@ -2348,8 +2348,8 @@ H5T_register(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
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);
H5I_dec_ref(tmp_sid, FALSE, FALSE);
H5I_dec_ref(tmp_did, FALSE, FALSE);
tmp_sid = tmp_did = -1;
H5E_clear_stack(NULL);
continue;
@ -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, FALSE, FALSE);
H5I_dec_ref(tmp_did, FALSE, FALSE);
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, FALSE, FALSE);
if(tmp_did >= 0)
H5I_dec_ref(tmp_did, FALSE);
H5I_dec_ref(tmp_did, FALSE, FALSE);
} /* 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, FALSE, FALSE);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
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, FALSE, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
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, FALSE, FALSE);
if(dst_id >= 0)
H5I_dec_ref(dst_id, FALSE);
H5I_dec_ref(dst_id, FALSE, FALSE);
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5T_path_find() */

View File

@ -664,7 +664,7 @@ 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);
(void)H5I_dec_ref(new_tcpl_id, TRUE, FALSE);
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_create_plist() */

View File

@ -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], FALSE, FALSE);
HDassert(status >= 0);
status = H5I_dec_ref(dst_memb_id[src2dst[i]], FALSE);
status = H5I_dec_ref(dst_memb_id[src2dst[i]], FALSE, FALSE);
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, FALSE, FALSE);
if(tdst_id >= 0)
H5I_dec_ref(tdst_id, FALSE);
H5I_dec_ref(tdst_id, FALSE, FALSE);
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, FALSE, FALSE);
if(tdst_id >= 0)
H5I_dec_ref(tdst_id, FALSE);
H5I_dec_ref(tdst_id, FALSE, FALSE);
break;
default: /* Some other command we don't know about yet.*/

View File

@ -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, FALSE, FALSE) < 0)
HDONE_ERROR(H5E_PLINE, H5E_CANTRELEASE, FAIL, "unable to close dataspace")
FUNC_LEAVE_NOAPI(ret_value)

View File

@ -38,8 +38,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
# other current library code tests.
TEST_PROG=testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 app_ref enum \
dtypes dsets cmpd_dset filter_fail extend external objcopy links unlink \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe \
getname vfd ntypes dangle dtransform reserved cross_read \
freespace mf farray earray btree2 fheap

View File

@ -80,9 +80,9 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \
cache_tagging$(EXEEXT) pool$(EXEEXT) hyperslab$(EXEEXT) \
istore$(EXEEXT) bittests$(EXEEXT) dt_arith$(EXEEXT) \
dtypes$(EXEEXT) dsets$(EXEEXT) cmpd_dset$(EXEEXT) \
extend$(EXEEXT) external$(EXEEXT) objcopy$(EXEEXT) \
links$(EXEEXT) unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) \
fillval$(EXEEXT) mount$(EXEEXT) flush1$(EXEEXT) \
filter_fail$(EXEEXT) extend$(EXEEXT) external$(EXEEXT) \
objcopy$(EXEEXT) links$(EXEEXT) unlink$(EXEEXT) big$(EXEEXT) \
mtime$(EXEEXT) fillval$(EXEEXT) mount$(EXEEXT) flush1$(EXEEXT) \
flush2$(EXEEXT) app_ref$(EXEEXT) enum$(EXEEXT) \
set_extent$(EXEEXT) ttsafe$(EXEEXT) getname$(EXEEXT) \
vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \
@ -190,6 +190,10 @@ fillval_SOURCES = fillval.c
fillval_OBJECTS = fillval.$(OBJEXT)
fillval_LDADD = $(LDADD)
fillval_DEPENDENCIES = libh5test.la $(LIBHDF5)
filter_fail_SOURCES = filter_fail.c
filter_fail_OBJECTS = filter_fail.$(OBJEXT)
filter_fail_LDADD = $(LDADD)
filter_fail_DEPENDENCIES = libh5test.la $(LIBHDF5)
flush1_SOURCES = flush1.c
flush1_OBJECTS = flush1.$(OBJEXT)
flush1_LDADD = $(LDADD)
@ -385,24 +389,24 @@ SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.c \
cache.c cache_api.c cache_tagging.c cmpd_dset.c cross_read.c \
dangle.c dsets.c dt_arith.c dtransform.c dtypes.c earray.c \
enum.c err_compat.c error_test.c extend.c external.c farray.c \
fheap.c fillval.c flush1.c flush2.c freespace.c gen_bad_ohdr.c \
gen_bogus.c gen_cross.c gen_deflate.c gen_filespace.c \
gen_filters.c gen_new_array.c gen_new_fill.c gen_new_group.c \
gen_new_mtime.c gen_new_super.c gen_noencoder.c \
gen_nullspace.c gen_sizes_lheap.c gen_specmetaread.c \
gen_udlinks.c getname.c gheap.c hyperslab.c istore.c lheap.c \
links.c mf.c mount.c mtime.c ntypes.c objcopy.c ohdr.c pool.c \
reserved.c set_extent.c space_overflow.c stab.c \
tcheck_version.c $(testhdf5_SOURCES) testmeta.c \
$(ttsafe_SOURCES) unlink.c vfd.c
fheap.c fillval.c filter_fail.c flush1.c flush2.c freespace.c \
gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \
gen_filespace.c gen_filters.c gen_new_array.c gen_new_fill.c \
gen_new_group.c gen_new_mtime.c gen_new_super.c \
gen_noencoder.c gen_nullspace.c gen_sizes_lheap.c \
gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \
istore.c lheap.c links.c mf.c mount.c mtime.c ntypes.c \
objcopy.c ohdr.c pool.c reserved.c set_extent.c \
space_overflow.c stab.c tcheck_version.c $(testhdf5_SOURCES) \
testmeta.c $(ttsafe_SOURCES) unlink.c vfd.c
DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \
btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \
cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \
earray.c enum.c err_compat.c error_test.c extend.c external.c \
farray.c fheap.c fillval.c flush1.c flush2.c freespace.c \
gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \
gen_filespace.c gen_filters.c gen_new_array.c gen_new_fill.c \
gen_new_group.c gen_new_mtime.c gen_new_super.c \
farray.c fheap.c fillval.c filter_fail.c flush1.c flush2.c \
freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \
gen_deflate.c gen_filespace.c gen_filters.c gen_new_array.c \
gen_new_fill.c gen_new_group.c gen_new_mtime.c gen_new_super.c \
gen_noencoder.c gen_nullspace.c gen_sizes_lheap.c \
gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \
istore.c lheap.c links.c mf.c mount.c mtime.c ntypes.c \
@ -717,8 +721,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT)
# other current library code tests.
TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \
pool hyperslab istore bittests dt_arith \
dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \
fillval mount flush1 flush2 app_ref enum \
dtypes dsets cmpd_dset filter_fail extend external objcopy links unlink \
big mtime fillval mount flush1 flush2 app_ref enum \
set_extent ttsafe \
getname vfd ntypes dangle dtransform reserved cross_read \
freespace mf farray earray btree2 fheap
@ -916,6 +920,9 @@ fheap$(EXEEXT): $(fheap_OBJECTS) $(fheap_DEPENDENCIES)
fillval$(EXEEXT): $(fillval_OBJECTS) $(fillval_DEPENDENCIES)
@rm -f fillval$(EXEEXT)
$(LINK) $(fillval_OBJECTS) $(fillval_LDADD) $(LIBS)
filter_fail$(EXEEXT): $(filter_fail_OBJECTS) $(filter_fail_DEPENDENCIES)
@rm -f filter_fail$(EXEEXT)
$(LINK) $(filter_fail_OBJECTS) $(filter_fail_LDADD) $(LIBS)
flush1$(EXEEXT): $(flush1_OBJECTS) $(flush1_DEPENDENCIES)
@rm -f flush1$(EXEEXT)
$(LINK) $(flush1_OBJECTS) $(flush1_LDADD) $(LIBS)
@ -1073,6 +1080,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farray.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fheap.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fillval.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filter_fail.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freespace.Po@am__quote@

382
test/filter_fail.c Normal file
View File

@ -0,0 +1,382 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Programmer: Raymond Lu <songyulu@hdfgroup.org>
* 7 September 2010
*
* Purpose: Make sure dataset, file, and library can close properly when a
* mandatory filter fails.
*/
#include "h5test.h"
#include "H5srcdir.h"
#define DSET_NAME "dset_fail"
#define ONE_MB 1048576
#define H5Z_FILTER_FAIL_TEST 312
#define DIM 10
#define FILTER_CHUNK_DIM 2
const char *FILENAME[] = {
"filter_fail",
NULL
};
static size_t filter_fail(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
/* This message derives from H5Z */
const H5Z_class2_t H5Z_FAIL_TEST[1] = {{
H5Z_CLASS_T_VERS, /* H5Z_class_t version */
H5Z_FILTER_FAIL_TEST, /* Filter id number */
1, 1, /* Encoding and decoding enabled */
"filter_fail_test", /* Filter name for debugging */
NULL, /* The "can apply" callback */
NULL, /* The "set local" callback */
filter_fail, /* The actual filter function */
}};
/*-------------------------------------------------------------------------
* Function: filter_fail
*
* Purpose: For testing library's behavior when a mandatory filter
* fails to write a chunk.
*
* Return: Success: Data chunk size
* Failure: 0
*
* Programmer: Raymond Lu
* 7 September 2010
*
*-------------------------------------------------------------------------
*/
static size_t
filter_fail(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes,
size_t *buf_size, void **buf)
{
int *dst = (int*)(*buf);
unsigned int offset;
unsigned int length;
unsigned int value;
size_t ret_value = 0;
if(flags & H5Z_FLAG_REVERSE) { /* do nothing during read */
*buf_size = nbytes;
ret_value = nbytes;
} /* end if */
else { /* Write data */
/* If it's the last chunk, pretend to fail. Otherwise, do nothing. */
if(*dst == 8 || *dst == 9) {
ret_value = 0;
} else {
*buf_size = nbytes;
ret_value = *buf_size;
}
} /* end else */
error:
return ret_value;
} /* end filter_fail() */
/*-------------------------------------------------------------------------
* Function: test_filter_write_failure
*
* Purpose: Tests the library's behavior when a mandate filter returns
* failure. There're only 5 chunks with each of them having
* 2 integers. The filter will fail in the last chunk. The
* dataset should release all resources even though the last
* chunk can't be flushed to file. The file should close
* successfully.
*
* Return:
* Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 25 August 2010
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
test_filter_write(char *file_name, hid_t my_fapl)
{
char filename[1024];
hid_t file = -1;
hid_t dataset=-1; /* dataset ID */
hid_t sid=-1; /* dataspace ID */
hid_t dcpl=-1; /* dataset creation property list ID */
hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/
hsize_t chunk_dims[1]={FILTER_CHUNK_DIM}; /* chunk dimension - 2*/
int nfilters; /* number of filters in DCPL */
unsigned flags; /* flags for filter */
int points[DIM]; /* Data */
int rbuf[DIM]; /* Data */
herr_t ret; /* generic return value */
int i;
TESTING("data writing when a mandatory filter fails");
/* Create file */
if((file = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR
/* create the data space */
if((sid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR
/* Create dcpl and register the filter */
if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR
if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) TEST_ERROR
if(H5Zregister (H5Z_FAIL_TEST) < 0) TEST_ERROR
/* Check that the filter was registered */
if(TRUE != H5Zfilter_avail(H5Z_FILTER_FAIL_TEST)) FAIL_STACK_ERROR
/* Enable the filter as mandatory */
if(H5Pset_filter(dcpl, H5Z_FILTER_FAIL_TEST, 0, (size_t)0, NULL) < 0)
TEST_ERROR
/* create a dataset */
if((dataset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR
/* Initialize the write buffer */
for(i = 0; i < DIM; i++)
points[i] = i;
/* Write data */
if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, points) < 0) TEST_ERROR
/* clean up objects used for this test */
if(H5Pclose (dcpl) < 0) TEST_ERROR
if(H5Sclose (sid) < 0) TEST_ERROR
/* Dataset closing should fail */
H5E_BEGIN_TRY {
ret = H5Dclose (dataset);
} H5E_END_TRY;
if(ret >= 0) {
H5_FAILED();
puts(" Dataset is supposed to fail because the chunk can't be flushed to file.");
TEST_ERROR
}
/* Even though H5Dclose fails, it should release all resources.
* So the file should close successfully. */
if(H5Fclose (file) < 0) TEST_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Pclose(dcpl);
H5Sclose(sid);
H5Dclose(dataset);
H5Fclose(file);
} H5E_END_TRY;
return -1;
} /* end test_filter_write() */
/*-------------------------------------------------------------------------
* Function: test_filter_read
*
* Purpose: Tests the library's behavior when a mandate filter returns
* failure. The first 4 chunks should be in the file. The
* last chunk should not.
*
* Return:
* Success: 0
* Failure: -1
*
* Programmer: Raymond Lu
* 25 August 2010
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
test_filter_read(char *file_name, hid_t my_fapl)
{
hid_t file = -1;
hid_t dataset=-1; /* dataset ID */
hid_t sid = -1;
hid_t mspace = -1;
hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/
hsize_t chunk_dims[1]={FILTER_CHUNK_DIM}; /* chunk dimension - 2*/
int rbuf[DIM]; /* Data */
hsize_t dset_size = 0; /* Dataset storage size */
hsize_t hs_offset[H5S_MAX_RANK];
hsize_t hs_size[H5S_MAX_RANK];
hsize_t stride[1] = {2};
hsize_t zero[8];
hsize_t nelmts = DIM/2;
int i;
TESTING("data reading when a mandatory filter fails");
/* Open file */
if((file = H5Fopen(file_name, H5F_ACC_RDONLY, my_fapl)) < 0) TEST_ERROR
/* Open dataset */
if((dataset = H5Dopen2(file, DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR
/* Verify the storage size is equal to 4 chunks */
if((dset_size = H5Dget_storage_size(dataset)) == 0) TEST_ERROR
if(dset_size != 4 * FILTER_CHUNK_DIM * sizeof(int)) TEST_ERROR
/* Read the chunks */
HDmemset(rbuf, 0, DIM * sizeof(int));
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0)
TEST_ERROR
/* Check that the values read are the same as the values written.
* The last chunk should not be in the file. */
for(i = 0; i < DIM; i++) {
if(i < DIM-2 && rbuf[i] != i) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d\n", i);
printf(" rbuf[%d]=%d\n", i, rbuf[i]);
TEST_ERROR
} else if(i >= DIM-2 && rbuf[i] != 0) {
H5_FAILED();
printf(" No value should be read.\n");
printf(" At index %d\n", i);
printf(" rbuf[%d]=%d\n", i, rbuf[i]);
TEST_ERROR
}
}
/* Try to read in hyperslab simulating the h5dump's way of printing data */
if((sid = H5Dget_space(dataset)) < 0) TEST_ERROR
HDmemset(hs_offset, 0, sizeof(hs_offset));
HDmemset(hs_size, 0, sizeof(hs_size));
hs_size[0] = DIM/2;
if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, stride, hs_size, NULL) < 0)
TEST_ERROR
/* create the data space */
if((mspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR
HDmemset(zero, 0, sizeof zero);
if(H5Sselect_hyperslab(mspace, H5S_SELECT_SET, zero, stride, &nelmts, NULL) < 0)
TEST_ERROR
HDmemset(rbuf, 0, DIM * sizeof(int));
if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rbuf) < 0)
TEST_ERROR
/* Check that the values read are the same as the values written.
* The last chunk should not be in the file. */
for(i = 0; i < DIM; i+=2) {
if(i < DIM-2 && rbuf[i] != i) {
H5_FAILED();
printf(" Read different values than written.\n");
printf(" At index %d\n", i);
printf(" rbuf[%d]=%d\n", i, rbuf[i]);
TEST_ERROR
} else if(i >= DIM-2 && rbuf[i] != 0) {
H5_FAILED();
printf(" No value should be read.\n");
printf(" At index %d\n", i);
printf(" rbuf[%d]=%d\n", i, rbuf[i]);
TEST_ERROR
}
}
if(H5Sclose (sid) < 0) TEST_ERROR
if(H5Sclose (mspace) < 0) TEST_ERROR
if(H5Dclose (dataset) < 0) TEST_ERROR
if(H5Fclose (file) < 0) TEST_ERROR
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Sclose(sid);
H5Sclose(mspace);
H5Dclose(dataset);
H5Fclose(file);
} H5E_END_TRY;
return -1;
} /* end test_filter_read() */
/*-------------------------------------------------------------------------
* Function: main
*
* Purpose: Tests the library's behavior when a mandate filter returns
* failure.
*
* Return: Success: exit(0)
* Failure: exit(1)
*
* Programmer: Raymond Lu
* 25 August 2010
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int main(void)
{
hid_t fapl;
int mdc_nelmts = 0;
size_t rdcc_nelmts = 521;
size_t rdcc_nbytes = ONE_MB;
double rdcc_w0 = 0.75;
char filename[1024];
unsigned nerrors = 0;
h5_reset();
fapl = h5_fileaccess();
h5_fixname(FILENAME[0], fapl, filename, sizeof filename);
/* Make sure the chunk cache is used. All values are default. */
if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0)
TEST_ERROR
nerrors += (test_filter_write(filename, fapl) < 0 ? 1 : 0);
nerrors += (test_filter_read(filename, fapl) < 0 ? 1 : 0);
h5_cleanup(FILENAME, fapl);
/* Make sure we can close the library */
if(H5close() < 0) TEST_ERROR
if (nerrors) TEST_ERROR
return 0;
error:
if (nerrors) {
printf("***** %u FAILURE%s! *****\n",
nerrors, 1==nerrors?"":"S");
HDexit(1);
}
}

View File

@ -361,7 +361,7 @@ static int test_is_valid(void)
CHECK(ret, FAIL, "H5I_inc_ref");
if (ret < 0)
goto out;
ret = H5I_dec_ref(dtype, TRUE);
ret = H5I_dec_ref(dtype, TRUE, FALSE);
CHECK(ret, FAIL, "H5I_dec_ref");
if (ret < 0)
goto out;
@ -377,7 +377,7 @@ static int test_is_valid(void)
CHECK(nmembs1, FAIL, "H5I_nmembers");
if (nmembs1 < 0)
goto out;
ret = H5I_dec_ref(dtype, FALSE);
ret = H5I_dec_ref(dtype, FALSE, FALSE);
CHECK(ret, FAIL, "H5I_dec_ref");
if (ret < 0)
goto out;