summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5AC.c2
-rw-r--r--src/H5ACprivate.h2
-rw-r--r--src/H5B.c124
-rw-r--r--src/H5Gnode.c47
-rw-r--r--src/H5HG.c27
-rw-r--r--src/H5HGdbg.c13
-rw-r--r--src/H5HL.c16
-rw-r--r--src/H5HLdbg.c15
-rw-r--r--src/H5O.c14
9 files changed, 201 insertions, 59 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index e6053b2..f8890d8 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -453,6 +453,7 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
}
+#if 0
/*-------------------------------------------------------------------------
* Function: H5AC_find
@@ -677,6 +678,7 @@ H5AC_find(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
done:
FUNC_LEAVE_NOAPI(ret_value)
}
+#endif /* 0 */
/*-------------------------------------------------------------------------
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 632de1f..79fd4e8 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -139,8 +139,6 @@ H5_DLL void *H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, had
const void *udata1, void *udata2);
H5_DLL herr_t H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
void *thing, hbool_t deleted);
-H5_DLL void *H5AC_find(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type,
- haddr_t addr, const void *udata1, void *udata2);
H5_DLL herr_t H5AC_flush(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
unsigned flags);
H5_DLL herr_t H5AC_rename(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type,
diff --git a/src/H5B.c b/src/H5B.c
index e8fdb15..87575f1 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -828,7 +828,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr
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")
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
tmp_bt=NULL; /* Make certain future references will be caught */
}
@@ -979,23 +979,47 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
assert(H5B_INS_RIGHT == my_ins);
/* the current root */
- 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 locate root of B-tree")
+
level = bt->level;
+
if (!lt_key_changed) {
- if (!bt->key[0].nkey && H5B_decode_key(f, bt, 0) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key")
+ if (!bt->key[0].nkey && H5B_decode_key(f, bt, 0) < 0) {
+ /* We want the actual error to show up but also want to
+ * execute the "H5AC_unprotect" call. So we use the
+ * "HCOMMON_ERROR" macro. */
+ HCOMMON_ERROR(H5E_BTREE, H5E_CANTDECODE, "unable to decode key");
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
+ HGOTO_DONE(FAIL)
+ }
+
HDmemcpy(lt_key, bt->key[0].nkey, type->sizeof_nkey);
}
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
bt = NULL;
/* the new node */
- 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 node")
+
if (!rt_key_changed) {
if (!bt->key[bt->nchildren].nkey &&
- H5B_decode_key(f, bt, bt->nchildren) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key")
+ H5B_decode_key(f, bt, bt->nchildren) < 0) {
+ HCOMMON_ERROR(H5E_BTREE, H5E_CANTDECODE, "unable to decode key");
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
+ HGOTO_DONE(FAIL)
+ }
+
HDmemcpy(rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey);
}
@@ -1005,9 +1029,14 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
* from "moving".
*/
size = H5B_nodesize(f, type, NULL, bt->sizeof_rkey);
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
+ bt = NULL;
+
if (HADDR_UNDEF==(old_root=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root")
- bt = NULL;
/* update the new child's left pointer */
if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, child, type, udata)))
@@ -1017,7 +1046,8 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
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")
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
bt=NULL; /* Make certain future references will be caught */
/*
@@ -1033,11 +1063,18 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
bt->cache_info.dirty = TRUE;
/* Make a copy of the old root information */
- if (NULL == (new_bt = H5B_copy(f, bt)))
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to copy old root")
+ if (NULL == (new_bt = H5B_copy(f, bt))) {
+ HCOMMON_ERROR(H5E_BTREE, H5E_CANTLOAD, "unable to copy old root");
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
+ HGOTO_DONE(FAIL)
+ }
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
- HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+
bt=NULL; /* Make certain future references will be caught */
/* Move the location of the old root on the disk */
@@ -1544,6 +1581,8 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
uint8_t *key = NULL;
unsigned nchildren; /* Number of children of B-tree node */
unsigned u; /* Local index variable */
+ int level;
+ haddr_t left_child;
herr_t ret_value;
FUNC_ENTER_NOAPI(H5B_iterate, FAIL)
@@ -1557,11 +1596,20 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
assert(H5F_addr_defined(addr));
assert(udata);
- 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 node")
- if (bt->level > 0) {
+
+ level = bt->level;
+ left_child = bt->child[0];
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+
+ bt = NULL; /* Make certain future references will be caught */
+
+ if (level > 0) {
/* Keep following the left-most child until we reach a leaf node. */
- if ((ret_value=H5B_iterate(f, dxpl_id, type, op, bt->child[0], udata))<0)
+ if ((ret_value=H5B_iterate(f, dxpl_id, type, op, left_child, udata))<0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node")
} else {
/*
@@ -1571,26 +1619,39 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op
if (NULL==(child=H5FL_ARR_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) ||
NULL==(key=H5MM_malloc((2*H5F_KVALUE(f, type)+1)*type->sizeof_nkey)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) {
+ for (cur_addr=addr, ret_value=0; H5F_addr_defined(cur_addr) && !ret_value; cur_addr=next_addr) {
/*
* Save all the child addresses and native keys since we can't
* leave the B-tree node protected during an application
* callback.
*/
- if (NULL==(bt=H5AC_find (f, dxpl_id, H5AC_BT, cur_addr, type, udata)))
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node")
+ if (NULL == (bt = H5AC_protect(f, dxpl_id, H5AC_BT, cur_addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node")
+
for (u=0; u<bt->nchildren; u++)
child[u] = bt->child[u];
+
for (u=0; u<bt->nchildren+1; u++) {
if (!bt->key[u].nkey) {
- if (H5B_decode_key(f, bt, u) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key")
+ if (H5B_decode_key(f, bt, u) < 0) {
+ HCOMMON_ERROR(H5E_BTREE, H5E_CANTDECODE, "unable to decode key")
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, cur_addr, bt, FALSE) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+
+ HGOTO_DONE(FAIL)
+ }
} /* end if */
HDmemcpy(key+u*type->sizeof_nkey, bt->key[u].nkey, type->sizeof_nkey);
}
+
next_addr = bt->right;
nchildren = bt->nchildren;
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, cur_addr, bt, FALSE) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+
bt = NULL;
/*
@@ -1774,7 +1835,8 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
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")
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
+
sibling=NULL; /* Make certain future references will be caught */
}
if (H5F_addr_defined(bt->right)) {
@@ -1785,7 +1847,8 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
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")
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node from tree")
+
sibling=NULL; /* Make certain future references will be caught */
}
bt->left = HADDR_UNDEF;
@@ -1883,8 +1946,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
} else {
ret_value = H5B_INS_NOOP;
}
-
-
+
done:
if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE)<0 && ret_value>=0)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node")
@@ -1949,7 +2011,8 @@ H5B_remove(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
}
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node")
+
bt=NULL; /* Make certain future references will be caught */
#ifdef H5B_DEBUG
@@ -2225,7 +2288,7 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
/*
* Load the tree node.
*/
- 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 node")
/*
@@ -2296,6 +2359,9 @@ H5B_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int f
}
done:
+ if (bt && H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) < 0)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node")
+
FUNC_LEAVE_NOAPI(ret_value)
}
@@ -2342,7 +2408,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
}
}
/* Initialize the queue */
- bt = H5AC_find(f, dxpl_id, H5AC_BT, addr, type, udata);
+ bt = H5AC_protect(f, dxpl_id, H5AC_BT, addr, type, udata);
assert(bt);
cur = H5MM_calloc(sizeof(struct child_t));
assert (cur);
@@ -2350,6 +2416,10 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
cur->level = bt->level;
head = tail = cur;
+ status = H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE);
+ assert(status >= 0);
+ bt=NULL; /* Make certain future references will be caught */
+
/*
* Do a breadth-first search of the tree. New nodes are added to the end
* of the queue as the `cur' pointer is advanced toward the end. We don't
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 423ed57..875c4c4 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1009,8 +1009,11 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key,
}
}
- if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) != SUCCEED)
- HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node");
+ if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) != SUCCEED) {
+ snrt = NULL;
+ HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node");
+ }
+
snrt=NULL; /* Make certain future references will be caught */
} else {
/* Where to insert the new entry? */
@@ -1283,13 +1286,19 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
* Save information about the symbol table node since we can't lock it
* because we're about to call an application function.
*/
- if (NULL == (sn = H5AC_find(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
+ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node");
nsyms = sn->nsyms;
if (NULL==(name_off = H5MM_malloc (nsyms*sizeof(name_off[0]))))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, H5B_ITER_ERROR, "memory allocation failed");
for (i=0; i<nsyms; i++)
name_off[i] = sn->entry[i].name_off;
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED) {
+ sn = NULL;
+ HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header");
+ }
+
sn=NULL; /* Make certain future references will be caught */
/*
@@ -1322,6 +1331,9 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
HERROR (H5E_SYM, H5E_CANTNEXT, "iteration operator failed");
done:
+ if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header");
+
name_off = H5MM_xfree (name_off);
FUNC_LEAVE_NOAPI(ret_value);
}
@@ -1360,9 +1372,14 @@ H5G_node_sumup(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
assert(num_objs);
/* Find the object node and add the number of symbol entries. */
- if (NULL == (sn = H5AC_find(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
+ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node");
+
*num_objs += sn->nsyms;
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header");
+
sn=NULL; /* Make certain future references will be caught */
done:
@@ -1406,8 +1423,7 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
assert(H5F_addr_defined(addr));
assert(bt_udata);
-
- if (NULL == (sn = H5AC_find(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
+ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node");
/* Find the node, locate the object symbol table entry and retrieve the name */
@@ -1417,10 +1433,14 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
name = H5HL_peek (f, dxpl_id, bt_udata->ent->cache.stab.heap_addr, name_off);
assert (name);
bt_udata->name = H5MM_strdup (name);
- HGOTO_DONE(H5B_ITER_STOP);
+ ret_value = H5B_ITER_STOP;
+ } else {
+ bt_udata->num_objs += sn->nsyms;
}
- bt_udata->num_objs += sn->nsyms;
+ if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header");
+
sn=NULL; /* Make certain future references will be caught */
done:
@@ -1460,16 +1480,20 @@ H5G_node_type(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
assert(bt_udata);
/* Find the node, locate the object symbol table entry and retrieve the type */
- if (NULL == (sn = H5AC_find(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
+ if (NULL == (sn = H5AC_protect(f, dxpl_id, H5AC_SNODE, addr, NULL, NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_ITER_ERROR, "unable to load symbol table node");
if(bt_udata->idx >= bt_udata->num_objs && bt_udata->idx < (bt_udata->num_objs+sn->nsyms)) {
loc_idx = bt_udata->idx - bt_udata->num_objs;
bt_udata->type = H5G_get_type(&(sn->entry[loc_idx]), dxpl_id);
- HGOTO_DONE(H5B_ITER_STOP);
+ ret_value = H5B_ITER_STOP;
+ } else {
+ bt_udata->num_objs += sn->nsyms;
}
- bt_udata->num_objs += sn->nsyms;
+ if (H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to release object header");
+
sn=NULL; /* Make certain future references will be caught */
done:
@@ -1551,6 +1575,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent,
}
H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, FALSE);
+ sn = NULL;
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5HG.c b/src/H5HG.c
index 4c81a93..922c2ca 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -765,15 +765,16 @@ H5HG_peek (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
assert (hobj);
/* Load the heap and return a pointer to the object */
- if (NULL==(heap=H5AC_find(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL)))
HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
+
assert (hobj->idx>0 && hobj->idx<heap->nalloc);
ret_value = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR (f);
assert (ret_value);
/*
- * Advance the heap in the CWFS list. We might have done this already
- * with the H5AC_find(), but it won't hurt to do it twice.
+ * Advance the heap in the CWFS list. We might have done this already
+ * with the H5AC_protect(), but it won't hurt to do it twice.
*/
if (heap->obj[0].begin) {
for (i=0; i<f->shared->ncwfs; i++) {
@@ -786,6 +787,10 @@ H5HG_peek (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
}
}
}
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header");
+
heap=NULL;
done:
@@ -829,8 +834,9 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/)
assert (hobj);
/* Load the heap */
- if (NULL==(heap=H5AC_find(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_GHEAP, hobj->addr, NULL, NULL)))
HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
+
assert (hobj->idx>0 && hobj->idx<heap->nalloc);
assert (heap->obj[hobj->idx].begin);
size = heap->obj[hobj->idx].size;
@@ -840,8 +846,8 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/)
HDmemcpy (object, p, size);
/*
- * Advance the heap in the CWFS list. We might have done this already
- * with the H5AC_find(), but it won't hurt to do it twice.
+ * Advance the heap in the CWFS list. We might have done this already
+ * with the H5AC_protect(), but it won't hurt to do it twice.
*/
if (heap->obj[0].begin) {
for (i=0; i<f->shared->ncwfs; i++) {
@@ -854,12 +860,21 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/)
}
}
}
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED) {
+ heap = NULL;
+ HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header");
+ }
+
heap = NULL;
/* Set return value */
ret_value=object;
done:
+ if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED)
+ HDONE_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header");
+
FUNC_LEAVE_NOAPI(ret_value);
}
diff --git a/src/H5HGdbg.c b/src/H5HGdbg.c
index 128ba93..c8afd85 100644
--- a/src/H5HGdbg.c
+++ b/src/H5HGdbg.c
@@ -73,8 +73,9 @@ H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
assert(indent >= 0);
assert(fwidth >= 0);
- if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection");
+ if (NULL == (h = H5AC_protect(f, dxpl_id, H5AC_GHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection");
+
fprintf(stream, "%*sGlobal Heap Collection...\n", indent, "");
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
"Dirty:",
@@ -129,8 +130,12 @@ H5HG_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent,
}
}
}
-
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, addr, h, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header");
+
+ h = NULL;
+
done:
FUNC_LEAVE_NOAPI(ret_value);
}
-
diff --git a/src/H5HL.c b/src/H5HL.c
index e4044cb..332adf4 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -629,14 +629,19 @@ H5HL_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, voi
assert(f);
assert (H5F_addr_defined(addr));
- if (NULL == (heap = H5AC_find(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
+
assert(offset < heap->mem_alloc);
assert(offset + size <= heap->mem_alloc);
if (!buf && NULL==(buf = H5MM_malloc(size)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy(buf, heap->chunk + H5HL_SIZEOF_HDR(f) + offset, size);
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header");
+
heap=NULL;
/* Set return value */
@@ -691,12 +696,17 @@ H5HL_peek(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset)
assert(f);
assert(H5F_addr_defined(addr));
- if (NULL == (heap = H5AC_find(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
+ if (NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
+
assert(offset < heap->mem_alloc);
/* Set return value */
ret_value = heap->chunk + H5HL_SIZEOF_HDR(f) + offset;
+
+ if (H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, NULL, "unable to release object header");
+
heap=NULL;
done:
diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c
index 2e0be37..0277044 100644
--- a/src/H5HLdbg.c
+++ b/src/H5HLdbg.c
@@ -71,8 +71,9 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
assert(indent >= 0);
assert(fwidth >= 0);
- if (NULL == (h = H5AC_find(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
+ if (NULL == (h = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
+
fprintf(stream, "%*sLocal Heap...\n", indent, "");
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
"Dirty:",
@@ -93,11 +94,12 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
/*
* Traverse the free list and check that all free blocks fall within
* the heap and that no two free blocks point to the same region of
- * the heap.
- */
+ * the heap. */
if (NULL==(marker = H5MM_calloc(h->mem_alloc)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+
fprintf(stream, "%*sFree Blocks (offset, size):\n", indent, "");
+
for (free_block=0, freelist = h->freelist; freelist; freelist = freelist->next, free_block++) {
char temp_str[32];
@@ -166,6 +168,11 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, int
HDfputc('\n', stream);
}
+ if (H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, h, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+
+ h = NULL;
+
H5MM_xfree(marker);
done:
diff --git a/src/H5O.c b/src/H5O.c
index e34f750..14dfd74 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1332,13 +1332,17 @@ H5O_count_real (H5G_entry_t *ent, const H5O_class_t *type, hid_t dxpl_id)
assert (type);
/* Load the object header */
- if (NULL==(oh=H5AC_find(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL)))
+ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL)))
HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
for (u=acc=0; u<oh->nmesgs; u++) {
if (oh->mesg[u].type==type)
acc++;
}
+
+ if (H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+
oh=NULL;
/* Set return value */
@@ -1432,7 +1436,7 @@ H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t d
assert(sequence>=0);
/* Load the object header */
- if (NULL==(oh=H5AC_find(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL)))
+ if (NULL == (oh = H5AC_protect(ent->file, dxpl_id, H5AC_OHDR, ent->header, NULL, NULL)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
/* Scan through the messages looking for the right one */
@@ -1442,6 +1446,10 @@ H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t d
if (--sequence<0)
break;
}
+
+ if (H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) != SUCCEED)
+ HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+
oh=NULL;
/* Set return value */
@@ -2024,6 +2032,8 @@ H5O_unprotect(H5G_entry_t *ent, H5O_t *oh, hid_t dxpl_id)
if (H5AC_unprotect(ent->file, dxpl_id, H5AC_OHDR, ent->header, oh, FALSE) < 0)
HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+ oh = NULL;
+
done:
FUNC_LEAVE_NOAPI(ret_value);
} /* end H5O_unprotect() */