mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-01-18 15:15:56 +08:00
[svn-r11295] Purpose:
Bug fix Description: Fix "strong" file closing to handle a dangling dataset which uses a dangling named datatype. Platforms tested: FreeBSD 4.11 (sleipnir) Too minor too require h5committest
This commit is contained in:
parent
4a6e1b6ba9
commit
ab6656c52c
17
src/H5F.c
17
src/H5F.c
@ -2677,8 +2677,21 @@ H5F_try_close(H5F_t *f)
|
|||||||
hid_t objs[128]; /* Array of objects to close */
|
hid_t objs[128]; /* Array of objects to close */
|
||||||
unsigned u; /* Local index variable */
|
unsigned u; /* Local index variable */
|
||||||
|
|
||||||
/* Get the list of IDs of open dataset, group, named datatype & attribute objects */
|
/* Get the list of IDs of open dataset, group, & attribute objects */
|
||||||
while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR, (int)(sizeof(objs)/sizeof(objs[0])), objs)) != 0) {
|
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)) != 0) {
|
||||||
|
|
||||||
|
/* Try to close all the open objects in this file */
|
||||||
|
for(u = 0; u < obj_count; u++)
|
||||||
|
if(H5I_dec_ref(objs[u]) < 0)
|
||||||
|
HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object")
|
||||||
|
} /* end while */
|
||||||
|
|
||||||
|
/* Get the list of IDs of open named datatype objects */
|
||||||
|
/* (Do this separately from the dataset & attribute IDs, because
|
||||||
|
* they could be using one of the named datatypes and then the
|
||||||
|
* open named datatype ID will get closed twice.
|
||||||
|
*/
|
||||||
|
while((obj_count = H5F_get_obj_ids(f, H5F_OBJ_LOCAL|H5F_OBJ_DATATYPE, (int)(sizeof(objs)/sizeof(objs[0])), objs)) != 0) {
|
||||||
|
|
||||||
/* Try to close all the open objects in this file */
|
/* Try to close all the open objects in this file */
|
||||||
for(u = 0; u < obj_count; u++)
|
for(u = 0; u < obj_count; u++)
|
||||||
|
100
test/dangle.c
100
test/dangle.c
@ -225,7 +225,7 @@ error:
|
|||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* Function: test_dangle_datatype
|
* Function: test_dangle_datatype1
|
||||||
*
|
*
|
||||||
* Purpose: Check for dangling datatype IDs causing problems on library
|
* Purpose: Check for dangling datatype IDs causing problems on library
|
||||||
* shutdown
|
* shutdown
|
||||||
@ -241,7 +241,7 @@ error:
|
|||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
test_dangle_datatype(H5F_close_degree_t degree)
|
test_dangle_datatype1(H5F_close_degree_t degree)
|
||||||
{
|
{
|
||||||
char filename[1024];
|
char filename[1024];
|
||||||
hid_t fid; /* File ID */
|
hid_t fid; /* File ID */
|
||||||
@ -320,6 +320,93 @@ error:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------
|
||||||
|
* Function: test_dangle_datatype2
|
||||||
|
*
|
||||||
|
* Purpose: Check for dangling datatype IDs causing problems on library
|
||||||
|
* shutdown
|
||||||
|
*
|
||||||
|
* Return: Success: zero
|
||||||
|
* Failure: non-zero
|
||||||
|
*
|
||||||
|
* Programmer: Quincey Koziol
|
||||||
|
* Thursday, August 25, 2005
|
||||||
|
*
|
||||||
|
* Modifications:
|
||||||
|
*
|
||||||
|
*-------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
test_dangle_datatype2(H5F_close_degree_t degree)
|
||||||
|
{
|
||||||
|
char filename[1024];
|
||||||
|
hid_t fid; /* File ID */
|
||||||
|
hid_t fapl; /* File access property list */
|
||||||
|
hid_t did; /* Dataset ID */
|
||||||
|
hid_t sid; /* Dataspace ID */
|
||||||
|
hid_t tid; /* Datatype ID */
|
||||||
|
|
||||||
|
TESTING(" dangling named datatype ID used by dataset");
|
||||||
|
|
||||||
|
if(H5open()<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
/* Create file access property list */
|
||||||
|
if((fapl=H5Pcreate(H5P_FILE_ACCESS))<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
/* Set file close degree */
|
||||||
|
if(H5Pset_fclose_degree(fapl,degree)<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename);
|
||||||
|
if((fid = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
if((tid = H5Tcopy (H5T_NATIVE_INT))<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
if(H5Tcommit(fid,TYPENAME,tid)<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
/* Create a dataset that uses the named datatype & leave it open */
|
||||||
|
if((sid = H5Screate(H5S_SCALAR)) < 0)
|
||||||
|
TEST_ERROR;
|
||||||
|
if((did = H5Dcreate(fid, DSETNAME, tid, sid, H5P_DEFAULT)) < 0)
|
||||||
|
TEST_ERROR;
|
||||||
|
if(H5Sclose(sid)<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
if(degree==H5F_CLOSE_SEMI) {
|
||||||
|
H5E_BEGIN_TRY {
|
||||||
|
if(H5Fclose(fid)>=0)
|
||||||
|
TEST_ERROR;
|
||||||
|
} H5E_END_TRY;
|
||||||
|
} /* end if */
|
||||||
|
else
|
||||||
|
if(H5Fclose(fid)<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
if(H5Pclose(fapl)<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
if(H5close()<0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
if(h5_get_file_size(filename)==0)
|
||||||
|
TEST_ERROR;
|
||||||
|
|
||||||
|
/* Clean up temporary file */
|
||||||
|
HDremove(filename);
|
||||||
|
|
||||||
|
PASSED();
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* Function: test_dangle_attribute
|
* Function: test_dangle_attribute
|
||||||
@ -453,21 +540,24 @@ main(void)
|
|||||||
puts("Testing dangling objects with weak file close:");
|
puts("Testing dangling objects with weak file close:");
|
||||||
nerrors += test_dangle_dataset(H5F_CLOSE_WEAK);
|
nerrors += test_dangle_dataset(H5F_CLOSE_WEAK);
|
||||||
nerrors += test_dangle_group(H5F_CLOSE_WEAK);
|
nerrors += test_dangle_group(H5F_CLOSE_WEAK);
|
||||||
nerrors += test_dangle_datatype(H5F_CLOSE_WEAK);
|
nerrors += test_dangle_datatype1(H5F_CLOSE_WEAK);
|
||||||
|
nerrors += test_dangle_datatype2(H5F_CLOSE_WEAK);
|
||||||
nerrors += test_dangle_attribute(H5F_CLOSE_WEAK);
|
nerrors += test_dangle_attribute(H5F_CLOSE_WEAK);
|
||||||
|
|
||||||
/* Run tests w/semi file close */
|
/* Run tests w/semi file close */
|
||||||
puts("Testing dangling objects with semi file close:");
|
puts("Testing dangling objects with semi file close:");
|
||||||
nerrors += test_dangle_dataset(H5F_CLOSE_SEMI);
|
nerrors += test_dangle_dataset(H5F_CLOSE_SEMI);
|
||||||
nerrors += test_dangle_group(H5F_CLOSE_SEMI);
|
nerrors += test_dangle_group(H5F_CLOSE_SEMI);
|
||||||
nerrors += test_dangle_datatype(H5F_CLOSE_SEMI);
|
nerrors += test_dangle_datatype1(H5F_CLOSE_SEMI);
|
||||||
|
nerrors += test_dangle_datatype2(H5F_CLOSE_SEMI);
|
||||||
nerrors += test_dangle_attribute(H5F_CLOSE_SEMI);
|
nerrors += test_dangle_attribute(H5F_CLOSE_SEMI);
|
||||||
|
|
||||||
/* Run tests w/strong file close */
|
/* Run tests w/strong file close */
|
||||||
puts("Testing dangling objects with strong file close:");
|
puts("Testing dangling objects with strong file close:");
|
||||||
nerrors += test_dangle_dataset(H5F_CLOSE_STRONG);
|
nerrors += test_dangle_dataset(H5F_CLOSE_STRONG);
|
||||||
nerrors += test_dangle_group(H5F_CLOSE_STRONG);
|
nerrors += test_dangle_group(H5F_CLOSE_STRONG);
|
||||||
nerrors += test_dangle_datatype(H5F_CLOSE_STRONG);
|
nerrors += test_dangle_datatype1(H5F_CLOSE_STRONG);
|
||||||
|
nerrors += test_dangle_datatype2(H5F_CLOSE_STRONG);
|
||||||
nerrors += test_dangle_attribute(H5F_CLOSE_STRONG);
|
nerrors += test_dangle_attribute(H5F_CLOSE_STRONG);
|
||||||
|
|
||||||
/* Check for errors */
|
/* Check for errors */
|
||||||
|
Loading…
Reference in New Issue
Block a user