[svn-r19354] Quincey and I made H5Eset_current_stack also close the stack to be set. This is to avoid

H5Eclose_stack clearing the default stack.  Please see bug 1799.

Tested on jam - simple change.
This commit is contained in:
Raymond Lu 2010-09-07 10:41:55 -05:00
parent c5bfe49ea6
commit ad0134f2a6
3 changed files with 82 additions and 1 deletions

View File

@ -237,6 +237,9 @@ Bug Fixes since HDF5-1.8.0 release
Library
-------
- H5Eset_current_stack now also closes the error stack to be set as the
default. This is to avoid a potential problem (Bug 1799).
(SLU - 2010/9/7)
- Fixed the bug in the filter's public CAN_APPLY function. The return
value should be htri_t not herr_t (Bug #1239). (SLU - 2010/8/5)
- Fixed a bug in the direct I/O driver that could render files with

View File

@ -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_ref(err_stack, TRUE) < 0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTDEC, FAIL, "unable to decrement ref count on error stack")
} /* end if */
done:

View File

@ -515,6 +515,68 @@ error:
return(-1);
} /* end test_create() */
/*-------------------------------------------------------------------------
* Function: test_copy
*
* Purpose: Test copyinging an error stack
*
* Return: Success: 0
* Failure: -1
*
* Programmer: Allen Byrne
* February 18, 2010
*
*-------------------------------------------------------------------------
*/
static herr_t
test_copy(void)
{
const char *err_func = "test_copy"; /* Function name for pushing error */
const char *err_msg = "Error message"; /* Error message for pushing error */
int err_num; /* Number of errors on stack */
int err_num_copy; /* Number of errors on stack copy */
hid_t estack_id; /* Error stack ID */
herr_t ret; /* Generic return value */
/* Push an error with a long description */
if(H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, err_msg) < 0) TEST_ERROR;
/* Check the number of errors on stack */
err_num = H5Eget_num(H5E_DEFAULT);
if(err_num != 1) TEST_ERROR
/* Copy error stack, which clears the original */
if((estack_id = H5Eget_current_stack()) < 0) TEST_ERROR
/* Check the number of errors on stack copy */
err_num = H5Eget_num(estack_id);
if(err_num != 1) TEST_ERROR
/* Check the number of errors on original stack */
err_num = H5Eget_num(H5E_DEFAULT);
if(err_num != 0) TEST_ERROR
/* Put the stack copy as the default. It closes the stack copy, too. */
if(H5Eset_current_stack(estack_id) < 0) TEST_ERROR
/* Check the number of errors on default stack */
err_num = H5Eget_num(H5E_DEFAULT);
if(err_num != 1) TEST_ERROR
/* Try to close error stack copy. Should fail because
* the current H5Eset_current_stack closes the stack to be set.*/
H5E_BEGIN_TRY {
ret = H5Eclose_stack(estack_id);
} H5E_END_TRY
if(ret >= 0) TEST_ERROR
return(0);
error:
return(-1);
} /* end test_copy() */
/*-------------------------------------------------------------------------
* Function: close_error
@ -624,6 +686,9 @@ main(void)
/* Test creating a new error stack */
if(test_create() < 0) TEST_ERROR;
/* Test copying a new error stack */
if(test_copy() < 0) TEST_ERROR;
if(H5Fclose(file) < 0) TEST_ERROR;
h5_cleanup(FILENAME, fapl);