From 831be1cdff55df0e00163d0069171bbdde2b1d25 Mon Sep 17 00:00:00 2001 From: James Laird Date: Thu, 5 Oct 2006 15:30:07 -0500 Subject: [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) --- src/H5F.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 -- cgit v0.12