From 535172c8fb0ba9078cdaedf26cd36009864e0d99 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 21 Apr 2003 13:30:55 -0500 Subject: [svn-r6720] Purpose: Bug Fix Description: A resource leak happened if the H5Fget_access_plist() function was called. What was happening: the driver ID and info parts of the property list copied in H5Fget_access_plist were being overwritten, but those properties were copied initially, so we lost information. Added calls to the H5Fget_access_plist function to get the PList and then immediately close it. It would cause an infinite loop if there is a resource leak. Solution: Before copying over those values, call the H5F_acs_close() function to close those values. Platforms tested: Modi4 (Parallel & Fortran) Arabica (Fortran) Verbena (Fortran & C++) Misc. update: --- test/file_handle.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/test/file_handle.c b/test/file_handle.c index be7e762..cf255e8 100644 --- a/test/file_handle.c +++ b/test/file_handle.c @@ -54,7 +54,7 @@ const char *FILENAME[] = { static herr_t test_sec2(void) { - hid_t file=(-1), fapl; + hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; int *fhandle=NULL; @@ -69,6 +69,14 @@ test_sec2(void) if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; + /* Retrieve the access property list... */ + if ((access_fapl = H5Fget_access_plist(file)) < 0) + goto error; + + /* ...and close the property list */ + if (H5Pclose(access_fapl) < 0) + goto error; + /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle)<0) goto error; @@ -109,7 +117,7 @@ error: static herr_t test_core(void) { - hid_t file=(-1), fapl; + hid_t file=(-1), fapl, access_fapl = -1; char filename[1024]; void *fhandle=NULL; @@ -123,7 +131,15 @@ test_core(void) if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; - + + /* Retrieve the access property list... */ + if ((access_fapl = H5Fget_access_plist(file)) < 0) + goto error; + + /* ...and close the property list */ + if (H5Pclose(access_fapl) < 0) + goto error; + if(H5Fget_vfd_handle(file, H5P_DEFAULT, &fhandle)<0) goto error; if(fhandle==NULL) @@ -167,6 +183,7 @@ static herr_t test_family(void) { hid_t file=(-1), fapl, fapl2=(-1), space=(-1), dset=(-1); + hid_t access_fapl = -1; char filename[1024]; char dname[]="dataset"; int i, j; @@ -188,6 +205,15 @@ test_family(void) /* Create and write dataset */ if((space=H5Screate_simple(2, dims, NULL))<0) goto error; + + /* Retrieve the access property list... */ + if ((access_fapl = H5Fget_access_plist(file)) < 0) + goto error; + + /* ...and close the property list */ + if (H5Pclose(access_fapl) < 0) + goto error; + if((dset=H5Dcreate(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT))<0) goto error; @@ -259,6 +285,7 @@ static herr_t test_multi(void) { hid_t file=(-1), fapl, fapl2=(-1), dset=(-1), space=(-1); + hid_t access_fapl = -1; char filename[1024]; int *fhandle2=NULL, *fhandle=NULL; H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; @@ -305,6 +332,15 @@ test_multi(void) /* Create and write data set */ if((space=H5Screate_simple(2, dims, NULL))<0) goto error; + + /* Retrieve the access property list... */ + if ((access_fapl = H5Fget_access_plist(file)) < 0) + goto error; + + /* ...and close the property list */ + if (H5Pclose(access_fapl) < 0) + goto error; + if((dset=H5Dcreate(file, dname, H5T_NATIVE_INT, space, H5P_DEFAULT))<0) goto error; -- cgit v0.12