summaryrefslogtreecommitdiffstats
path: root/src/H5Oshared.c
diff options
context:
space:
mode:
authorPeter Cao <xcao@hdfgroup.org>2007-05-30 21:35:57 (GMT)
committerPeter Cao <xcao@hdfgroup.org>2007-05-30 21:35:57 (GMT)
commit461b896779cb585cf47236cdcfc271a98d3ca080 (patch)
tree9ad39b91c1b22826d0281ea8d916abaac5f03b5f /src/H5Oshared.c
parent7afc8fc6ebaaedf4d077b8ca1558e6bac8afc373 (diff)
downloadhdf5-461b896779cb585cf47236cdcfc271a98d3ca080.zip
hdf5-461b896779cb585cf47236cdcfc271a98d3ca080.tar.gz
hdf5-461b896779cb585cf47236cdcfc271a98d3ca080.tar.bz2
[svn-r13821]
Fixed a bug at copying shared reg_ref attribute. The ref values of an attribute was not writen in file. The post_copy_file() at H5Oattr.c only updates the value in memory. To fix the problem, we added H5O_shared_post_copy_file(), which delete the attribute in file (with the incorrect value) and create an new attribute with the correct values. I added the following functions: H5Oshared.c:H5O_shared_post_copy_file(H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *mesg); H5Oshared.h: H5O_SHARED_POST_COPY_FILE and modified the following files to include shared_post_copy_file() H5Oattr.c H5Odtype.c H5Ofill.c H5Opline.c H5Osdspace.c
Diffstat (limited to 'src/H5Oshared.c')
-rw-r--r--src/H5Oshared.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index 44b0992..e78a1d3 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -578,6 +578,60 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O_shared_post_copy_file
+ *
+ * Purpose: Delate a shared message and replace with a new one.
+ * The function is needed at cases such as coping a shared reg_ref attribute.
+ * When a shared reg_ref attribute is copied from one file to
+ * another, the values in file need to be replaced. The only way
+ * to complish that is to delete the old message and write the
+ * new message with the correct values.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Peter Cao
+ * xcao@hdfgroup.org
+ * May 24 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_shared_post_copy_file(H5F_t *f, hid_t dxpl_id, H5O_t *oh, void *mesg)
+{
+ H5O_shared_t *old_sh_mesg;
+ htri_t shared_mesg; /* Whether the message should be shared */
+ unsigned msg_type_id; /* Message's type ID */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5O_shared_post_copy_file)
+
+ /* check args */
+ HDassert(f);
+ HDassert(mesg);
+
+ /* the old shared message */
+ old_sh_mesg = (H5O_shared_t *) mesg;
+
+ /* save the type id for later use */
+ msg_type_id = old_sh_mesg->msg_type_id;
+
+ /* Remove the old message from the SOHM storage */
+ if(H5SM_delete(f, dxpl_id, oh, old_sh_mesg) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to find attribute information for object")
+
+ /* Add the new message */
+ if((shared_mesg = H5SM_try_share(f, dxpl_id, oh, msg_type_id, mesg, NULL)) == 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "message changed sharing status")
+ else if(shared_mesg < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "can't share message")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_shared_post_copy_file() */
+
+
+
+/*-------------------------------------------------------------------------
* Function: H5O_shared_debug
*
* Purpose: Prints debugging info for the message