summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/H5Aint.c2
-rw-r--r--src/H5Dearray.c4
-rw-r--r--src/H5Dfarray.c4
-rw-r--r--src/H5Dint.c11
-rw-r--r--src/H5Dvirtual.c4
-rw-r--r--src/H5F.c2
-rw-r--r--src/H5Fefc.c8
-rw-r--r--src/H5Fint.c23
-rw-r--r--src/H5Fmount.c4
-rw-r--r--src/H5Fprivate.h5
-rw-r--r--src/H5Fquery.c25
-rw-r--r--src/H5Fsuper.c2
-rw-r--r--src/H5Gint.c17
-rw-r--r--src/H5Gtraverse.c2
-rw-r--r--src/H5O.c15
-rw-r--r--src/H5Ocopy.c2
-rw-r--r--src/H5Oprivate.h2
-rw-r--r--src/H5SM.c2
-rw-r--r--src/H5T.c4
-rw-r--r--src/H5Tcommit.c6
20 files changed, 71 insertions, 73 deletions
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 66af0ff..e31cd83 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -1050,7 +1050,7 @@ H5A_close(H5A_t *attr)
HDassert(attr->shared);
/* Close the object's symbol-table entry */
- if(attr->obj_opened && (H5O_close(&(attr->oloc)) < 0))
+ if(attr->obj_opened && (H5O_close(&(attr->oloc), NULL) < 0))
HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release object header info")
/* Reference count can be 0. It only happens when H5A_create fails. */
diff --git a/src/H5Dearray.c b/src/H5Dearray.c
index 9f95b30..3f12e97 100644
--- a/src/H5Dearray.c
+++ b/src/H5Dearray.c
@@ -657,7 +657,7 @@ H5D__earray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info")
/* close the object header */
- if(H5O_close(&obj_loc) < 0)
+ if(H5O_close(&obj_loc, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header")
/* Create user data */
@@ -676,7 +676,7 @@ done:
/* Close object header */
if(obj_opened) {
- if(H5O_close(&obj_loc) < 0)
+ if(H5O_close(&obj_loc, NULL) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header")
} /* end if */
} /* end if */
diff --git a/src/H5Dfarray.c b/src/H5Dfarray.c
index 5f82e59..212f1f1 100644
--- a/src/H5Dfarray.c
+++ b/src/H5Dfarray.c
@@ -497,7 +497,7 @@ H5D__farray_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr)
HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get layout info")
/* close the object header */
- if(H5O_close(&obj_loc) < 0)
+ if(H5O_close(&obj_loc, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header")
/* Create user data */
@@ -516,7 +516,7 @@ done:
/* Close object header */
if(obj_opened) {
- if(H5O_close(&obj_loc) < 0)
+ if(H5O_close(&obj_loc, NULL) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEOBJ, NULL, "can't close object header")
} /* end if */
} /* end if */
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 1f34c81..5a11581 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -1303,7 +1303,7 @@ done:
if(H5F_addr_defined(new_dset->oloc.addr)) {
if(H5O_dec_rc_by_loc(&(new_dset->oloc), dxpl_id) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object")
- if(H5O_close(&(new_dset->oloc)) < 0)
+ if(H5O_close(&(new_dset->oloc), NULL) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release object header")
if(file) {
if(H5O_delete(file, dxpl_id, new_dset->oloc.addr) < 0)
@@ -1738,7 +1738,7 @@ H5D__open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id)
done:
if(ret_value < 0) {
- if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc)) < 0)
+ if(H5F_addr_defined(dataset->oloc.addr) && H5O_close(&(dataset->oloc), NULL) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header")
if(dataset->shared) {
if(layout_init)
@@ -1782,6 +1782,7 @@ H5D_close(H5D_t *dataset)
{
hbool_t free_failed = FALSE; /* Set if freeing sub-components failed */
hbool_t corked; /* Whether the dataset is corked or not */
+ hbool_t file_closed = TRUE; /* H5O_close also closed the file? */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -1915,11 +1916,11 @@ H5D_close(H5D_t *dataset)
/* Close the dataset object */
/* (This closes the file, if this is the last object open) */
- if(H5O_close(&(dataset->oloc)) < 0)
+ if(H5O_close(&(dataset->oloc), &file_closed) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release object header")
/* Evict dataset metadata if evicting on close */
- if(!H5F_CLOSING(dataset->oloc.file) && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) {
+ if(!file_closed && H5F_SHARED(dataset->oloc.file) && H5F_EVICT_ON_CLOSE(dataset->oloc.file)) {
if(H5AC_flush_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, H5AC_ind_read_dxpl_id) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata")
if(H5AC_evict_tagged_metadata(dataset->oloc.file, dataset->oloc.addr, FALSE, H5AC_ind_read_dxpl_id) < 0)
@@ -1943,7 +1944,7 @@ H5D_close(H5D_t *dataset)
/* Check reference count for this object in the top file */
if(H5FO_top_count(dataset->oloc.file, dataset->oloc.addr) == 0) {
- if(H5O_close(&(dataset->oloc)) < 0)
+ if(H5O_close(&(dataset->oloc), NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to close")
} /* end if */
else
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index 9a90fa7..3780b88 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -807,7 +807,7 @@ H5D__virtual_open_source_dset(const H5D_t *vdset,
done:
/* Close source file */
if(src_file_open)
- if(H5F_try_close(src_file) < 0)
+ if(H5F_try_close(src_file, NULL) < 0)
HDONE_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "can't close source file")
FUNC_LEAVE_NOAPI(ret_value)
@@ -2931,7 +2931,7 @@ H5D__virtual_release_source_dset_files(H5D_virtual_held_file_t *head)
* essentially "private" to the virtual dataset, since it wasn't
* opened through an API routine -QAK)
*/
- if(H5F_try_close(head->file) < 0)
+ if(H5F_try_close(head->file, NULL) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close")
/* Delete node */
diff --git a/src/H5F.c b/src/H5F.c
index c70f813..f663036 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -580,7 +580,7 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
new_file->file_id = ret_value;
done:
- if(ret_value < 0 && new_file && H5F_try_close(new_file) < 0)
+ if(ret_value < 0 && new_file && H5F_try_close(new_file, NULL) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file")
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Fefc.c b/src/H5Fefc.c
index 5e3deb1..42bf5d8 100644
--- a/src/H5Fefc.c
+++ b/src/H5Fefc.c
@@ -301,7 +301,7 @@ done:
if(ent) {
if(open_file) {
ent->file->nopen_objs--;
- if(H5F_try_close(ent->file) < 0)
+ if(H5F_try_close(ent->file, NULL) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close external file")
} /* end if */
ent->name = (char *)H5MM_xfree(ent->name);
@@ -350,7 +350,7 @@ H5F_efc_close(H5F_t *parent, H5F_t *file)
* on the state of the efc. */
if(!efc) {
file->nopen_objs--;
- if(H5F_try_close(file) < 0)
+ if(H5F_try_close(file, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file")
HGOTO_DONE(SUCCEED)
@@ -364,7 +364,7 @@ H5F_efc_close(H5F_t *parent, H5F_t *file)
for(ent = efc->LRU_head; ent && ent->file != file; ent = ent->LRU_next);
if(!ent) {
file->nopen_objs--;
- if(H5F_try_close(file) < 0)
+ if(H5F_try_close(file, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file")
} /* end if */
else
@@ -572,7 +572,7 @@ H5F_efc_remove_ent(H5F_efc_t *efc, H5F_efc_ent_t *ent)
* However we must still manipulate the nopen_objs field to prevent the file
* from being closed out from under us. */
ent->file->nopen_objs--;
- if(H5F_try_close(ent->file) < 0)
+ if(H5F_try_close(ent->file, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close external file")
ent->file = NULL;
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() */
diff --git a/src/H5Fmount.c b/src/H5Fmount.c
index adde071..e3d4952 100644
--- a/src/H5Fmount.c
+++ b/src/H5Fmount.c
@@ -69,7 +69,7 @@ H5F_close_mounts(H5F_t *f)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close child group")
/* Close the child file */
- if(H5F_try_close(f->shared->mtab.child[u].file) < 0)
+ if(H5F_try_close(f->shared->mtab.child[u].file, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close child file")
/* Eliminate the mount point from the table */
@@ -386,7 +386,7 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id)
/* Detach child file from parent & see if it should close */
child->parent = NULL;
- if(H5F_try_close(child) < 0)
+ if(H5F_try_close(child, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close unmounted file")
done:
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index fdf82ed..9dd4f52 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -304,7 +304,6 @@
#define H5F_FCPL(F) ((F)->shared->fcpl_id)
#define H5F_GET_FC_DEGREE(F) ((F)->shared->fc_degree)
#define H5F_EVICT_ON_CLOSE(F) ((F)->shared->evict_on_close)
-#define H5F_CLOSING(F) ((F)->closing)
#define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots)
#define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes)
#define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0)
@@ -354,7 +353,6 @@
#define H5F_FCPL(F) (H5F_get_fcpl(F))
#define H5F_GET_FC_DEGREE(F) (H5F_get_fc_degree(F))
#define H5F_EVICT_ON_CLOSE(F) (H5F_get_evict_on_close(F))
-#define H5F_CLOSING(F) (H5F_get_closing(F))
#define H5F_RDCC_NSLOTS(F) (H5F_rdcc_nslots(F))
#define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F))
#define H5F_RDCC_W0(F) (H5F_rdcc_w0(F))
@@ -639,7 +637,7 @@ typedef struct H5F_block_t {
/* Private functions */
H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id,
hid_t fapl_id, hid_t dxpl_id);
-H5_DLL herr_t H5F_try_close(H5F_t *f);
+H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/);
/* Functions than retrieve values from the file struct */
H5_DLL unsigned H5F_get_intent(const H5F_t *f);
@@ -675,7 +673,6 @@ H5_DLL herr_t H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes);
H5_DLL hid_t H5F_get_fcpl(const H5F_t *f);
H5_DLL H5F_close_degree_t H5F_get_fc_degree(const H5F_t *f);
H5_DLL hbool_t H5F_get_evict_on_close(const H5F_t *f);
-H5_DLL hbool_t H5F_get_closing(const H5F_t *f);
H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f);
H5_DLL size_t H5F_rdcc_nslots(const H5F_t *f);
H5_DLL double H5F_rdcc_w0(const H5F_t *f);
diff --git a/src/H5Fquery.c b/src/H5Fquery.c
index e5e785e..55a50fd 100644
--- a/src/H5Fquery.c
+++ b/src/H5Fquery.c
@@ -863,31 +863,6 @@ H5F_get_evict_on_close(const H5F_t *f)
/*-------------------------------------------------------------------------
- * Function: H5F_get_closing
- *
- * Purpose: Checks if the file is in the process of being closed.
- *
- * Return: Success: Flag indicating whether the file is closing.
- * Failure: (can't happen)
- *
- * Programmer: Dana Robinson
- * Fall 2016
- *
- *-------------------------------------------------------------------------
- */
-hbool_t
-H5F_get_closing(const H5F_t *f)
-{
- /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- HDassert(f);
-
- FUNC_LEAVE_NOAPI(f->closing)
-} /* end H5F_get_closing() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5F_store_msg_crt_idx
*
* Purpose: Retrieve the 'store message creation index' flag for the file.
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 66b34bc..489a149 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -208,7 +208,7 @@ H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hid_t dxpl_id,
/* Twiddle the number of open objects to avoid closing the file. */
f->nopen_objs++;
- if(H5O_close(ext_ptr) < 0)
+ if(H5O_close(ext_ptr, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close superblock extension")
f->nopen_objs--;
diff --git a/src/H5Gint.c b/src/H5Gint.c
index 95682d9..72cc1a4 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -232,7 +232,7 @@ done:
if(oloc_init) {
if(H5O_dec_rc_by_loc(&(grp->oloc), dxpl_id) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object")
- if(H5O_close(&(grp->oloc)) < 0)
+ if(H5O_close(&(grp->oloc), NULL) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release object header")
if(H5O_delete(file, dxpl_id, grp->oloc.addr) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTDELETE, NULL, "unable to delete object header")
@@ -448,7 +448,7 @@ H5G_open_oid(H5G_t *grp, hid_t dxpl_id)
done:
if(ret_value < 0) {
if(obj_opened)
- H5O_close(&(grp->oloc));
+ H5O_close(&(grp->oloc), NULL);
if(grp->shared)
grp->shared = H5FL_FREE(H5G_shared_t, grp->shared);
} /* end if */
@@ -472,8 +472,9 @@ done:
herr_t
H5G_close(H5G_t *grp)
{
- hbool_t corked; /* Whether the group is corked or not */
- herr_t ret_value = SUCCEED; /* Return value */
+ hbool_t corked; /* Whether the group is corked or not */
+ hbool_t file_closed = TRUE; /* H5O_close also closed the file? */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -498,11 +499,11 @@ H5G_close(H5G_t *grp)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
if(H5FO_delete(grp->oloc.file, H5AC_ind_read_dxpl_id, grp->oloc.addr) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't remove group from list of open objects")
- if(H5O_close(&(grp->oloc)) < 0)
+ if(H5O_close(&(grp->oloc), &file_closed) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close")
/* Evict group metadata if evicting on close */
- if(!H5F_CLOSING(grp->oloc.file) && H5F_SHARED(grp->oloc.file) && H5F_EVICT_ON_CLOSE(grp->oloc.file)) {
+ if(!file_closed && H5F_SHARED(grp->oloc.file) && H5F_EVICT_ON_CLOSE(grp->oloc.file)) {
if(H5AC_flush_tagged_metadata(grp->oloc.file, grp->oloc.addr, H5AC_ind_read_dxpl_id) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush tagged metadata")
if(H5AC_evict_tagged_metadata(grp->oloc.file, grp->oloc.addr, FALSE, H5AC_ind_read_dxpl_id) < 0)
@@ -518,7 +519,7 @@ H5G_close(H5G_t *grp)
/* Check reference count for this object in the top file */
if(H5FO_top_count(grp->oloc.file, grp->oloc.addr) == 0) {
- if(H5O_close(&(grp->oloc)) < 0)
+ if(H5O_close(&(grp->oloc), NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close")
} /* end if */
else
@@ -531,7 +532,7 @@ H5G_close(H5G_t *grp)
*/
if(grp->shared->mounted && grp->shared->fo_count == 1) {
/* Attempt to close down the file hierarchy */
- if(H5F_try_close(grp->oloc.file) < 0)
+ if(H5F_try_close(grp->oloc.file, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close")
} /* end if */
} /* end else */
diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c
index 4d84e9f..d6c90e4 100644
--- a/src/H5Gtraverse.c
+++ b/src/H5Gtraverse.c
@@ -727,7 +727,7 @@ H5G_traverse_real(const H5G_loc_t *_loc, const char *name, unsigned target,
HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
/* Close new group */
- if(H5O_close(obj_loc.oloc) < 0)
+ if(H5O_close(obj_loc.oloc, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close")
/* If the parent group was holding the file open, the
diff --git a/src/H5O.c b/src/H5O.c
index f12bfed..713be04 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1558,7 +1558,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_close(H5O_loc_t *loc)
+H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1569,6 +1569,15 @@ H5O_close(H5O_loc_t *loc)
HDassert(loc->file);
HDassert(H5F_NOPEN_OBJS(loc->file) > 0);
+ /* Set the file_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(file_closed)
+ *file_closed = FALSE;
+
/* Decrement open-lock counters */
H5F_DECR_NOPEN_OBJS(loc->file);
@@ -1589,7 +1598,7 @@ H5O_close(H5O_loc_t *loc)
*/
if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file))
/* Attempt to close down the file hierarchy */
- if(H5F_try_close(loc->file) < 0)
+ if(H5F_try_close(loc->file, file_closed) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close")
/* Release location information */
@@ -2782,7 +2791,7 @@ H5O_loc_free(H5O_loc_t *loc)
H5F_DECR_NOPEN_OBJS(loc->file);
loc->holding_file = FALSE;
if(H5F_NOPEN_OBJS(loc->file) <= 0) {
- if(H5F_try_close(loc->file) < 0)
+ if(H5F_try_close(loc->file, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file")
} /* end if */
} /* end if */
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index d056ae8..c1c72cf 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -277,7 +277,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
done:
if(loc_found && H5G_loc_free(&src_loc) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location")
- if(obj_open && H5O_close(&src_oloc) < 0)
+ if(obj_open && H5O_close(&src_oloc, NULL) < 0)
HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, FAIL, "unable to release object header")
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index e8ba267..2169906 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -827,7 +827,7 @@ H5_DLL herr_t H5O_init(void);
H5_DLL herr_t H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint,
size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc/*out*/);
H5_DLL herr_t H5O_open(H5O_loc_t *loc);
-H5_DLL herr_t H5O_close(H5O_loc_t *loc);
+H5_DLL herr_t H5O_close(H5O_loc_t *loc, hbool_t *file_closed/*out*/);
H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust, hid_t dxpl_id);
H5_DLL H5O_t *H5O_protect(const H5O_loc_t *loc, hid_t dxpl_id, unsigned prot_flags);
H5_DLL H5O_t *H5O_pin(const H5O_loc_t *loc, hid_t dxpl_id);
diff --git a/src/H5SM.c b/src/H5SM.c
index 730e9e0..642bf7c 100644
--- a/src/H5SM.c
+++ b/src/H5SM.c
@@ -2467,7 +2467,7 @@ done:
if(oh && oh != open_oh) {
if(oh && H5O_unprotect(&oloc, dxpl_id, oh, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_SOHM, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
- if(H5O_close(&oloc) < 0)
+ if(H5O_close(&oloc, NULL) < 0)
HDONE_ERROR(H5E_SOHM, H5E_CANTCLOSEOBJ, FAIL, "unable to close object header")
} /* end if */
diff --git a/src/H5T.c b/src/H5T.c
index b2575d5..0fb8b91 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3525,7 +3525,7 @@ H5T__free(H5T_t *dt)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't decrement count for object")
if(H5FO_delete(dt->sh_loc.file, H5AC_ind_read_dxpl_id, dt->sh_loc.u.loc.oh_addr) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "can't remove datatype from list of open objects")
- if(H5O_close(&dt->oloc) < 0)
+ if(H5O_close(&dt->oloc, NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header")
dt->shared->state = H5T_STATE_NAMED;
} /* end if */
@@ -3645,7 +3645,7 @@ H5T_close(H5T_t *dt)
/* Check reference count for this object in the top file */
if(H5FO_top_count(dt->sh_loc.file, dt->sh_loc.u.loc.oh_addr) == 0) {
/* Close object location for named datatype */
- if(H5O_close(&dt->oloc) < 0)
+ if(H5O_close(&dt->oloc, NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close")
} /* end if */
else
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index 07fe371..3ded7af 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -203,7 +203,7 @@ done:
HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't remove dataset from list of open objects")
/* Close the datatype object */
- if(H5O_close(&(dt->oloc)) < 0)
+ if(H5O_close(&(dt->oloc), NULL) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
/* Remove the datatype's object header from the file */
@@ -401,7 +401,7 @@ done:
if((type->shared->state == H5T_STATE_TRANSIENT || type->shared->state == H5T_STATE_RDONLY) && (type->sh_loc.type == H5O_SHARE_TYPE_COMMITTED)) {
if(H5O_dec_rc_by_loc(&(type->oloc), dxpl_id) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
- if(H5O_close(&(type->oloc)) < 0)
+ if(H5O_close(&(type->oloc), NULL) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release object header")
if(H5O_delete(file, dxpl_id, type->sh_loc.u.loc.oh_addr) < 0)
HDONE_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "unable to delete object header")
@@ -823,7 +823,7 @@ H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id)
done:
if(ret_value == NULL)
if(dt == NULL)
- H5O_close(loc->oloc);
+ H5O_close(loc->oloc, NULL);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T_open_oid() */