summaryrefslogtreecommitdiffstats
path: root/src/H5Ocopy.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2010-03-05 17:24:17 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2010-03-05 17:24:17 (GMT)
commit179b54da83f293948a531afd6b59e676df7a60e7 (patch)
treef57b410bccb7fa311043f7a4451f4ca11d8463d7 /src/H5Ocopy.c
parent3a06e04ac5abb30d241118b83e2fc280e981a0b3 (diff)
downloadhdf5-179b54da83f293948a531afd6b59e676df7a60e7.zip
hdf5-179b54da83f293948a531afd6b59e676df7a60e7.tar.gz
hdf5-179b54da83f293948a531afd6b59e676df7a60e7.tar.bz2
[svn-r18374] Purpose: Fix bugs involving external links
Description: Previously, the library would reopen the source file when traversing an external link if unable to find the target file otherwise. This has been corrected. Also moved the call to H5F_flush from H5F_try_close to H5F_dest, so the file is only flushed when the last identifier for the file is closed. This prevernts situations where the library could attempt to flush a file with protected metadata. Tested: jam, amani, linew (h5committest); Fedora
Diffstat (limited to 'src/H5Ocopy.c')
-rw-r--r--src/H5Ocopy.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index 8bdbed5..1712706 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -946,6 +946,7 @@ H5O_copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name,
H5G_name_t new_path; /* Copied object group hier. path */
H5O_loc_t new_oloc; /* Copied object object location */
H5G_loc_t new_loc; /* Group location of object copied */
+ H5F_t *cached_dst_file; /* Cached destination file */
hbool_t entry_inserted=FALSE; /* Flag to indicate that the new entry was inserted into a group */
unsigned cpy_option = 0; /* Copy options */
herr_t ret_value = SUCCEED; /* Return value */
@@ -972,10 +973,19 @@ H5O_copy_obj(H5G_loc_t *src_loc, H5G_loc_t *dst_loc, const char *dst_name,
H5G_loc_reset(&new_loc);
new_oloc.file = dst_loc->oloc->file;
+ /* Make a copy of the destination file, in case the original is changed by
+ * H5O_copy_header. If and when oloc's point to the shared file struct,
+ * this will no longer be necessary, so this code can be removed. */
+ cached_dst_file = dst_loc->oloc->file;
+
/* Copy the object from the source file to the destination file */
if(H5O_copy_header(src_loc->oloc, &new_oloc, dxpl_id, cpy_option) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
+ /* Patch dst_loc. Again, this can be removed once oloc's point to shared
+ * file structs. */
+ dst_loc->oloc->file = cached_dst_file;
+
/* Insert the new object in the destination file's group */
if(H5L_link(dst_loc, dst_name, &new_loc, lcpl_id, H5P_DEFAULT, dxpl_id) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert link")