summaryrefslogtreecommitdiffstats
path: root/src/H5Oattribute.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-12-22 18:23:08 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-12-22 18:23:08 (GMT)
commitb1c318eebe05605f5086fb79cfd7e88d4b949bcf (patch)
tree6d5061822fc6856971c94f2568ce6c754127b798 /src/H5Oattribute.c
parente3fe4f7790d6289c8736a20736448d86686751fa (diff)
downloadhdf5-b1c318eebe05605f5086fb79cfd7e88d4b949bcf.zip
hdf5-b1c318eebe05605f5086fb79cfd7e88d4b949bcf.tar.gz
hdf5-b1c318eebe05605f5086fb79cfd7e88d4b949bcf.tar.bz2
[svn-r13086] Added deletion test for shared messages. I'm not sure that this test is
as complete as it could be, so I may add to it later. Fixed a bug in reference counting messages that are referenced by shared messages (attribute datatypes and dataspaces). Tested on mir, smirom, and Windows.
Diffstat (limited to 'src/H5Oattribute.c')
-rw-r--r--src/H5Oattribute.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c
index a7aeb79..ce7a8e5 100644
--- a/src/H5Oattribute.c
+++ b/src/H5Oattribute.c
@@ -562,6 +562,24 @@ H5O_attr_write_cb(H5O_t UNUSED *oh, H5O_mesg_t *mesg/*in,out*/,
if(HDstrcmp(shared_attr.name, udata->attr->name) == 0) {
htri_t shared_mesg; /* Whether the message should be shared */
+ /* Re-share attribute's datatype and dataspace to increment their
+ * reference count if they're shared.
+ * Otherwise they may be deleted when the old attribute
+ * message is deleted.
+ */
+ if(H5SM_try_share(udata->f, udata->dxpl_id, H5O_DTYPE_ID, udata->attr->dt) < 0)
+ HGOTO_ERROR(H5E_SOHM, H5E_BADMESG, H5_ITER_ERROR, "error trying to re-share attribute datatype")
+ if(H5SM_try_share(udata->f, udata->dxpl_id, H5O_SDSPACE_ID, udata->attr->ds) < 0)
+ HGOTO_ERROR(H5E_SOHM, H5E_BADMESG, H5_ITER_ERROR, "error trying to re-share attribute datatype")
+
+ /* Likewise, increment reference count if this attribute has a named datatype */
+ /* JAMES: this is identical to the attr_link callback. */
+ if(H5T_committed(udata->attr->dt)) {
+ /* Increment the reference count on the shared datatype */
+ if(H5T_link(udata->attr->dt,1,udata->dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
+ } /* end if */
+
/* Store new version of message as a SOHM */
/* (should always work, since we're not changing the size of the attribute) */
if((shared_mesg = H5SM_try_share(udata->f, udata->dxpl_id, H5O_ATTR_ID, udata->attr)) == 0)