diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2003-09-10 18:33:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2003-09-10 18:33:48 (GMT) |
commit | 9c31ce9a7b2b98416c0bfd90bccc277693341083 (patch) | |
tree | 054188ce5f221a96f23af38d098804a48a48e7ea /src | |
parent | 0282f2219bdeaf8b7bcd9141b20e4bf02d3a5301 (diff) | |
download | hdf5-9c31ce9a7b2b98416c0bfd90bccc277693341083.zip hdf5-9c31ce9a7b2b98416c0bfd90bccc277693341083.tar.gz hdf5-9c31ce9a7b2b98416c0bfd90bccc277693341083.tar.bz2 |
[svn-r7458] 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
Diffstat (limited to 'src')
-rw-r--r-- | src/H5F.c | 47 |
1 files changed, 25 insertions, 22 deletions
@@ -3102,36 +3102,39 @@ H5F_close(H5F_t *f) H5AC_debug(f); H5F_istore_stats(f, FALSE); + /* 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... */ - if (H5FD_is_fphdf5_driver(f->shared->lf)) - MPI_Barrier(H5FP_SAP_BARRIER_COMM); + /* Let's all meet up now... */ + if (H5FD_is_fphdf5_driver(f->shared->lf)) + MPI_Barrier(H5FP_SAP_BARRIER_COMM); #endif /* H5_HAVE_FPHDF5 */ + } /* end if */ } /* end if */ /* |