summaryrefslogtreecommitdiffstats
path: root/src/H5Ocopy.c
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2010-03-05 17:46:56 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2010-03-05 17:46:56 (GMT)
commit3b921a4b4f651ec07b69502b3d42ab5799e0038a (patch)
tree22c80156cd19e6f1114c26ab5761112f94659c09 /src/H5Ocopy.c
parent81896b337eacd9333a8cfc45676e1f6be0d08436 (diff)
downloadhdf5-3b921a4b4f651ec07b69502b3d42ab5799e0038a.zip
hdf5-3b921a4b4f651ec07b69502b3d42ab5799e0038a.tar.gz
hdf5-3b921a4b4f651ec07b69502b3d42ab5799e0038a.tar.bz2
[svn-r18375] 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")