summaryrefslogtreecommitdiffstats
path: root/src/H5Adense.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-01-08 22:25:26 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-01-08 22:25:26 (GMT)
commitd978a22b36d148a17f331eb51d0e13ede524770a (patch)
treee27cd9e51275efdbc7e626f94b24942c8c2fd7bf /src/H5Adense.c
parenta4527a631c6713b491aff80a4604dc21500540c4 (diff)
downloadhdf5-d978a22b36d148a17f331eb51d0e13ede524770a.zip
hdf5-d978a22b36d148a17f331eb51d0e13ede524770a.tar.gz
hdf5-d978a22b36d148a17f331eb51d0e13ede524770a.tar.bz2
[svn-r13121] Description:
Add support & tests for using shared datatypes with shared & un-shared attributes. Involves some fairly icky code to make the "copy on write" paradigm for shared attributes work. Tested on: Linux/32 2.6 (chicago) Linux/64 2.6 (chicago2)
Diffstat (limited to 'src/H5Adense.c')
-rw-r--r--src/H5Adense.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/H5Adense.c b/src/H5Adense.c
index d64bb89..e4cf59e 100644
--- a/src/H5Adense.c
+++ b/src/H5Adense.c
@@ -801,9 +801,29 @@ H5A_dense_rename(H5F_t *f, hid_t dxpl_id, const H5O_t *oh, const char *old_name,
/* Should this attribute be written as a SOHM? */
/* (allows for attributes that change "shared" status) */
- if((shared_mesg = H5SM_try_share(f, dxpl_id, H5O_ATTR_ID, attr_copy)) > 0)
+ if((shared_mesg = H5SM_try_share(f, dxpl_id, H5O_ATTR_ID, attr_copy)) > 0) {
+ hsize_t attr_rc; /* Attribute's ref count in shared message storage */
+
/* Mark the message as shared */
mesg_flags |= H5O_MSG_FLAG_SHARED;
+
+ /* Retrieve ref count for shared attribute */
+ if(H5SM_get_refcount(f, dxpl_id, H5O_ATTR_ID, &attr_copy->sh_loc, &attr_rc) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't retrieve shared message ref count")
+
+ /* If the newly shared attribute needs to share "ownership" of the shared
+ * components (ie. its reference count is 1), increment the reference
+ * count on any shared components of the attribute, so that they won't
+ * be removed from the file. (Essentially a "copy on write" operation).
+ *
+ * *ick* -QAK, 2007/01/08
+ */
+ if(attr_rc == 1) {
+ /* Increment reference count on attribute components */
+ if(H5O_attr_link(f, dxpl_id, attr_copy) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_LINKCOUNT, FAIL, "unable to adjust attribute link count")
+ } /* end if */
+ } /* end if */
else if(shared_mesg < 0)
HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "error determining if message should be shared")