summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-09-10 18:32:28 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-09-10 18:32:28 (GMT)
commit6a9188f0cb0ab63e858fee73c5261bbab4376c47 (patch)
tree7385cba61a82d379d320f7941ec35776ef1b40ec /src
parent6d928cf05ef860086825665cbfff18c6d1c15b3c (diff)
downloadhdf5-6a9188f0cb0ab63e858fee73c5261bbab4376c47.zip
hdf5-6a9188f0cb0ab63e858fee73c5261bbab4376c47.tar.gz
hdf5-6a9188f0cb0ab63e858fee73c5261bbab4376c47.tar.bz2
[svn-r7457] Purpose:
Bug fix. Description: Correct bug where a file opened twice, once with read-write permission and once with read-only permission would cause closing the file with the read-only file ID to fail because it was trying to flush information out of the file. Solution: Check the permissions on file IDs that are being closed and only flush when the particular file ID was opened with write permission. Platforms tested: FreeBSD 4.9 (sleipnir) too small to need h5committest Misc. update:
Diffstat (limited to 'src')
-rw-r--r--src/H5F.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/H5F.c b/src/H5F.c
index dc284cc..ae0363f 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -3103,38 +3103,41 @@ H5F_close(H5F_t *f)
H5F_istore_stats(f, FALSE);
#endif /* H5F_ISTORE_DEBUG */
+ /* Only try to flush the file if it was opened with write access */
+ if(f->intent&H5F_ACC_RDWR) {
#ifdef H5_HAVE_FPHDF5
- /*
- * We only want the captain to perform the flush of the metadata
- * to the file.
- */
- if (!H5FD_is_fphdf5_driver(f->shared->lf) ||
- H5FD_fphdf5_is_captain(f->shared->lf)) {
+ /*
+ * We only want the captain to perform the flush of the metadata
+ * to the file.
+ */
+ if (!H5FD_is_fphdf5_driver(f->shared->lf) ||
+ H5FD_fphdf5_is_captain(f->shared->lf)) {
#endif /* H5_HAVE_FPHDF5 */
- /* Flush and destroy all caches */
- if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
- H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
+ /* Flush and destroy all caches */
+ if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
+ H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
#ifdef H5_HAVE_FPHDF5
- } else {
- /*
- * If this isn't the captain process, flush but only clear
- * the flags.
- */
- if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
- H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING | H5F_FLUSH_CLEAR_ONLY) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
- }
+ } else {
+ /*
+ * If this isn't the captain process, flush but only clear
+ * the flags.
+ */
+ if (H5F_flush(f, H5AC_dxpl_id, H5F_SCOPE_LOCAL,
+ H5F_FLUSH_INVALIDATE | H5F_FLUSH_CLOSING | H5F_FLUSH_CLEAR_ONLY) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
+ }
- /* Let's all meet up now... */
- /* XXX: Calls which end up here are already required to be
- * collective, is this barrier really necessary? -QAK
- */
- if (H5FD_is_fphdf5_driver(f->shared->lf))
- MPI_Barrier(H5FP_SAP_BARRIER_COMM);
+ /* Let's all meet up now... */
+ /* XXX: Calls which end up here are already required to be
+ * collective, is this barrier really necessary? -QAK
+ */
+ if (H5FD_is_fphdf5_driver(f->shared->lf))
+ MPI_Barrier(H5FP_SAP_BARRIER_COMM);
#endif /* H5_HAVE_FPHDF5 */
+ } /* end if */
/*
* Destroy the H5F_t struct and decrement the reference count for the