summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-11-26 15:47:32 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-11-26 15:47:32 (GMT)
commita8d1aff23568c0f64fa16cfbb37d7741bb922a60 (patch)
tree153d5a07966aaed7755168df983bb2c3445bb1dd /src/H5Fint.c
parent72ecaf0940f8d6df7bedf14376ea3f2224efc0c6 (diff)
downloadhdf5-a8d1aff23568c0f64fa16cfbb37d7741bb922a60.zip
hdf5-a8d1aff23568c0f64fa16cfbb37d7741bb922a60.tar.gz
hdf5-a8d1aff23568c0f64fa16cfbb37d7741bb922a60.tar.bz2
Tentative fix for valgrind issues related to EoC.
Adds /*out*/ parameters to H5O_close() and H5F_try_close() so that H5D/G_close() will know when H5O_close() has triggered a file close and thus the file struct is not reliable. Also removes the H5F_CLOSING() macro and related which were formerly used to check if the file was closing.
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index dab1900..51a8ab5 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -1304,7 +1304,7 @@ H5F_close(H5F_t *f)
f->file_id = -1;
/* Attempt to close the file/mount hierarchy */
- if(H5F_try_close(f) < 0)
+ if(H5F_try_close(f, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file")
done:
@@ -1328,7 +1328,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5F_try_close(H5F_t *f)
+H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/)
{
unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */
unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */
@@ -1340,9 +1340,21 @@ H5F_try_close(H5F_t *f)
HDassert(f);
HDassert(f->shared);
+ /* Set the was_closed flag to the default value.
+ * This flag lets downstream code know if the file struct is
+ * still accessible and/or likely to contain useful data.
+ * It's needed by the evict-on-close code. Clients can ignore
+ * this value by passing in NULL.
+ */
+ if(was_closed)
+ *was_closed = FALSE;
+
/* Check if this file is already in the process of closing */
- if(f->closing)
+ if(f->closing) {
+ if(was_closed)
+ *was_closed = TRUE;
HGOTO_DONE(SUCCEED)
+ } /* end if */
/* Get the number of open objects and open files on this file/mount hierarchy */
if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0)
@@ -1443,7 +1455,7 @@ H5F_try_close(H5F_t *f)
* hierarchy if so.
*/
if(f->parent)
- if(H5F_try_close(f->parent) < 0)
+ if(H5F_try_close(f->parent, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close parent file")
/* Unmount and close each child before closing the current file. */
@@ -1469,6 +1481,9 @@ H5F_try_close(H5F_t *f)
if(H5F_dest(f, H5AC_ind_read_dxpl_id, TRUE) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file")
+ /* Since we closed the file, this should be set to TRUE */
+ if(was_closed)
+ *was_closed = TRUE;
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_try_close() */