summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-10-05 20:30:07 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-10-05 20:30:07 (GMT)
commit831be1cdff55df0e00163d0069171bbdde2b1d25 (patch)
tree560601ba2d14fc6c0a154fab6dcc903b1321e22a /src/H5F.c
parentc13697362a1bfa8f3a7e466f592d6baa6f925e12 (diff)
downloadhdf5-831be1cdff55df0e00163d0069171bbdde2b1d25.zip
hdf5-831be1cdff55df0e00163d0069171bbdde2b1d25.tar.gz
hdf5-831be1cdff55df0e00163d0069171bbdde2b1d25.tar.bz2
[svn-r12723] Fix a bug where return values were overwritten in H5F_dest, and another bug
exposed by that one in which closing a read/write file ID wouldn't flush the cache if there was another file handle open. This caused problems when the second file handle was read-only; neither would actually flush the cache. Now all read/write file handles flush the cache when the close, but only when the file is going to be destroyed is the cache destroyed. This way read-only file handles keep the cache open but it is always clean. Tested on mir, heping, sol, and copper (parallel)
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 322b980..a12c97d 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1657,7 +1657,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
if(H5I_GENPROP_LST != H5I_get_type(f->shared->fcpl_id))
/* Push error, but keep going*/
HDONE_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list")
- if((ret_value=H5I_dec_ref(f->shared->fcpl_id)) < 0)
+ if(H5I_dec_ref(f->shared->fcpl_id) < 0)
/* Push error, but keep going*/
HDONE_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't close property list")
@@ -2618,6 +2618,18 @@ H5F_try_close(H5F_t *f)
if(H5F_close_mounts(f) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't unmount child files")
+ /* Flush at this point since the file will be closed. Don't invalidate
+ * the cache, since this file might still be open using another handle.
+ * However, make sure we flush in case that handle is read-only; its
+ * copy of the cache needs to be clean.
+ * Only try to flush the file if it was opened with write access.
+ */
+ if(f->intent&H5F_ACC_RDWR) {
+ /* Flush and destroy all caches */
+ if(H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL, H5C__NO_FLAGS_SET) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
+ } /* end if */
+
/*
* Destroy the H5F_t struct and decrement the reference count for the
* shared H5F_file_t struct. If the reference count for the H5F_file_t