[svn-r20121] Bug 1586 - the datatype handler created with H5Tencode/decode had the reference count 0. I fixed it by changing the APP_REF parameter of H5I_register from FALSE to TRUE and added a test case in dtypes.c.

Tested on jam, heiwa, and amani.
This commit is contained in:
Raymond Lu 2011-02-18 14:01:34 -05:00
parent 40d2ecb45f
commit 4f75c8c24b
3 changed files with 85 additions and 17 deletions

View File

@ -264,6 +264,9 @@ Bug Fixes since HDF5-1.8.0 release
Library
-------
- The datatype handler created with H5Tencode/decode used to have the
reference count 0 (zero). I have fixed it. It is 1 (one) now.
(SLU - 2011/2/18)
- Fixed a bug that caused big endian machines to generate corrupt files
when using the scale-offset filter with floating point data or
fill values. Note that such datasets will no longer be readable

View File

@ -2807,6 +2807,11 @@ done:
* slu@ncsa.uiuc.edu
* July 14, 2004
*
* Modification:Raymond Lu
* songyulu@hdfgroup.org
* 17 February 2011
* I changed the value for the APP_REF parameter of H5I_register
* from FALSE to TRUE.
*-------------------------------------------------------------------------
*/
hid_t
@ -2827,7 +2832,7 @@ H5Tdecode(const void *buf)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "can't decode object")
/* Register the type and return the ID */
if((ret_value = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)
if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type")
done:

View File

@ -4900,6 +4900,10 @@ opaque_funcs(void)
* Modifications: Raymond Lu
* July 13, 2009
* Added the test for VL string types.
*
* Raymond Lu
* 17 February 2011
* I added the test of reference count for decoded datatypes.
*-------------------------------------------------------------------------
*/
static int
@ -5327,6 +5331,78 @@ test_encode(void)
goto error;
} /* end if */
/*-----------------------------------------------------------------------
* Test the reference count of the decoded datatypes
*-----------------------------------------------------------------------
*/
/* Make sure the reference counts for the decoded datatypes are one. */
if(H5Iget_ref(decoded_tid1) != 1) {
H5_FAILED();
printf("Decoded datatype has incorrect reference count\n");
goto error;
} /* end if */
if(H5Iget_ref(decoded_tid2) != 1) {
H5_FAILED();
printf("Decoded datatype has incorrect reference count\n");
goto error;
} /* end if */
if(H5Iget_ref(decoded_tid3) != 1) {
H5_FAILED();
printf("Decoded datatype has incorrect reference count\n");
goto error;
} /* end if */
/* Make sure the reference counts for the decoded datatypes can be
* decremented and the datatypes are closed. */
if(H5Idec_ref(decoded_tid1) != 0) {
H5_FAILED();
printf("Decoded datatype can't close\n");
goto error;
} /* end if */
if(H5Idec_ref(decoded_tid2) != 0) {
H5_FAILED();
printf("Decoded datatype can't close\n");
goto error;
} /* end if */
if(H5Idec_ref(decoded_tid3) != 0) {
H5_FAILED();
printf("Decoded datatype can't close\n");
goto error;
} /* end if */
/* Make sure the decoded datatypes are already closed. */
H5E_BEGIN_TRY {
ret = H5Tclose(decoded_tid1);
} H5E_END_TRY;
if(ret!=FAIL) {
H5_FAILED();
printf("Decoded datatype should have been closed\n");
goto error;
}
H5E_BEGIN_TRY {
ret = H5Tclose(decoded_tid2);
} H5E_END_TRY;
if(ret!=FAIL) {
H5_FAILED();
printf("Decoded datatype should have been closed\n");
goto error;
}
H5E_BEGIN_TRY {
ret = H5Tclose(decoded_tid3);
} H5E_END_TRY;
if(ret!=FAIL) {
H5_FAILED();
printf("Decoded datatype should have been closed\n");
goto error;
}
/*-----------------------------------------------------------------------
* Close and release
*-----------------------------------------------------------------------
@ -5348,22 +5424,6 @@ test_encode(void)
goto error;
} /* end if */
if(H5Tclose(decoded_tid1) < 0) {
H5_FAILED();
printf("Can't close datatype\n");
goto error;
} /* end if */
if(H5Tclose(decoded_tid2) < 0) {
H5_FAILED();
printf("Can't close datatype\n");
goto error;
} /* end if */
if(H5Tclose(decoded_tid3) < 0) {
H5_FAILED();
printf("Can't close datatype\n");
goto error;
} /* end if */
if(H5Fclose(file) < 0) {
H5_FAILED();
printf("Can't close file\n");