summaryrefslogtreecommitdiffstats
path: root/src/H5B.c
diff options
context:
space:
mode:
authorBill Wendling <wendling@ncsa.uiuc.edu>2003-09-04 21:43:37 (GMT)
committerBill Wendling <wendling@ncsa.uiuc.edu>2003-09-04 21:43:37 (GMT)
commitbd346629483722e7bae94521a33df4ec7a58bf0b (patch)
tree3e3dbb686c65cd01404457c35c71d652be602c56 /src/H5B.c
parent85637509083b9a0cc9b90f86865613a21a8d3968 (diff)
downloadhdf5-bd346629483722e7bae94521a33df4ec7a58bf0b.zip
hdf5-bd346629483722e7bae94521a33df4ec7a58bf0b.tar.gz
hdf5-bd346629483722e7bae94521a33df4ec7a58bf0b.tar.bz2
[svn-r7445] Purpose:
Fix, of a sort Description: Some of the code would get an object from the cache via the H5AC_find() function and then modify the returned object. This behavior is incorrect as the pointer returned via the H5AC_find() function is supposed to be read only. Solution: Changed the H5AC_finds to H5AC_protect() instead and added the appropriate H5AC_unprotect() function. Platforms tested: (simulated h5committest by hand since it doesn't work for me) Linux (Fortran, C++) Solaris (Fortran) AIX (Fortran, C++) SGI (Parallel, Fortran)
Diffstat (limited to 'src/H5B.c')
-rw-r--r--src/H5B.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/H5B.c b/src/H5B.c
index ca9fb47..41aafce 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -821,11 +821,16 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr
new_bt->right = old_bt->right;
if (H5F_addr_defined(old_bt->right)) {
- if (NULL == (tmp_bt = H5AC_find(f, dxpl_id, H5AC_BT, old_bt->right, type, udata)))
+ if (NULL == (tmp_bt = H5AC_protect(f, dxpl_id, H5AC_BT, old_bt->right, type, udata)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling")
+
tmp_bt->cache_info.dirty = TRUE;
tmp_bt->left = *new_addr_p;
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, old_bt->right, tmp_bt, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
}
+
old_bt->right = *new_addr_p;
done:
@@ -1001,23 +1006,30 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root")
/* update the new child's left pointer */
- if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, child, type, udata)))
+ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child")
+
bt->cache_info.dirty = TRUE;
bt->left = old_root;
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
/*
* Move the node to the new location by checking it out & checking it in
* at the new location -QAK
*/
/* Bring the old root into the cache if it's not already */
- if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata)))
+ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child")
/* Make certain the old root info is marked as dirty before moving it, */
/* so it is certain to be written out at the new location */
bt->cache_info.dirty = TRUE;
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
/* Make a copy of the old root information */
if (NULL == (bt = H5B_copy(f, bt)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to copy old root")
@@ -1749,16 +1761,24 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
bt->ndirty = 0;
if (level>0) {
if (H5F_addr_defined(bt->left)) {
- if (NULL==(sibling=H5AC_find(f, dxpl_id, H5AC_BT, bt->left, type, udata)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
+ if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->left, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node from tree")
+
sibling->right = bt->right;
sibling->cache_info.dirty = TRUE;
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->left, sibling, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
}
if (H5F_addr_defined(bt->right)) {
- if (NULL==(sibling=H5AC_find(f, dxpl_id, H5AC_BT, bt->right, type, udata)))
+ if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree")
+
sibling->left = bt->left;
sibling->cache_info.dirty = TRUE;
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, bt->right, sibling, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
}
bt->left = HADDR_UNDEF;
bt->right = HADDR_UNDEF;
@@ -1912,13 +1932,17 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
* If the B-tree is now empty then make sure we mark the root node as
* being at level zero
*/
- if (NULL==(bt=H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata)))
+ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node")
+
if (0==bt->nchildren && 0!=bt->level) {
bt->level = 0;
bt->cache_info.dirty = TRUE;
}
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
+
#ifdef H5B_DEBUG
H5B_assert(f, dxpl_id, addr, type, udata);
#endif