summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-09-06 18:54:16 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-09-06 18:54:16 (GMT)
commitb0d47e55f7a9274cc18458756b4e48dd8169ea43 (patch)
tree27a42b859d1772f63881b911924201fc2987f94a /src
parentbd346629483722e7bae94521a33df4ec7a58bf0b (diff)
downloadhdf5-b0d47e55f7a9274cc18458756b4e48dd8169ea43.zip
hdf5-b0d47e55f7a9274cc18458756b4e48dd8169ea43.tar.gz
hdf5-b0d47e55f7a9274cc18458756b4e48dd8169ea43.tar.bz2
[svn-r7446] Purpose:
Code cleanup/bug fix Description: Move metadata cache calls around a bit so they protect the usage of the metadata better. Platforms tested: FreeBSD 4.9 (sleipnir) too small to need h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5AC.c1
-rw-r--r--src/H5B.c69
-rw-r--r--src/H5Gnode.c7
-rw-r--r--src/H5HG.c11
-rw-r--r--src/H5HL.c2
-rw-r--r--src/H5O.c2
6 files changed, 58 insertions, 34 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index 605808f..e6053b2 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -1229,6 +1229,7 @@ H5AC_rename(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t old_addr,
* We don't need to do anything if the object isn't cached or if the
* new hash value is the same as the old one.
*/
+ assert(old_info);
if (H5F_addr_ne((*old_info)->addr, old_addr) || (*old_info)->type!=type)
HGOTO_DONE(SUCCEED)
if (old_idx == new_idx) {
diff --git a/src/H5B.c b/src/H5B.c
index 41aafce..e8fdb15 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -829,6 +829,7 @@ H5B_split(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_t *old_bt, haddr
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")
+ tmp_bt=NULL; /* Make certain future references will be caught */
}
old_bt->right = *new_addr_p;
@@ -954,6 +955,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
haddr_t child, old_root;
int level;
H5B_t *bt;
+ H5B_t *new_bt; /* Copy of B-tree info */
hsize_t size;
H5B_ins_t my_ins = H5B_INS_ERROR;
herr_t ret_value = SUCCEED;
@@ -985,6 +987,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key")
HDmemcpy(lt_key, bt->key[0].nkey, type->sizeof_nkey);
}
+ bt = NULL;
/* the new node */
if (NULL == (bt = H5AC_find(f, dxpl_id, H5AC_BT, child, type, udata)))
@@ -1004,6 +1007,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
size = H5B_nodesize(f, type, NULL, bt->sizeof_rkey);
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)))
@@ -1014,6 +1018,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, child, bt, FALSE) != SUCCEED)
HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release new child")
+ bt=NULL; /* Make certain future references will be caught */
/*
* Move the node to the new location by checking it out & checking it in
@@ -1027,44 +1032,45 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr,
/* 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)))
+ if (NULL == (new_bt = H5B_copy(f, bt)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to copy old root")
- /* Move the location on the disk */
+ if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, FALSE) != SUCCEED)
+ HDONE_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 */
if (H5AC_rename(f, dxpl_id, H5AC_BT, addr, old_root) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node")
- /* Insert the copy of the old root into the file again */
- if (H5AC_set(f, dxpl_id, H5AC_BT, addr, bt) < 0)
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to flush old B-tree root node")
-
/* clear the old root info at the old address (we already copied it) */
- bt->cache_info.dirty = TRUE;
- bt->left = HADDR_UNDEF;
- bt->right = HADDR_UNDEF;
+ new_bt->cache_info.dirty = TRUE;
+ new_bt->left = HADDR_UNDEF;
+ new_bt->right = HADDR_UNDEF;
/* Set the new information for the copy */
- bt->ndirty = 2;
- bt->level = level + 1;
- bt->nchildren = 2;
-
- bt->child[0] = old_root;
- bt->key[0].dirty = TRUE;
- bt->key[0].nkey = bt->native;
- HDmemcpy(bt->key[0].nkey, lt_key, type->sizeof_nkey);
-
- bt->child[1] = child;
- bt->key[1].dirty = TRUE;
- bt->key[1].nkey = bt->native + type->sizeof_nkey;
- HDmemcpy(bt->key[1].nkey, md_key, type->sizeof_nkey);
-
- bt->key[2].dirty = TRUE;
- bt->key[2].nkey = bt->native + 2 * type->sizeof_nkey;
- HDmemcpy(bt->key[2].nkey, rt_key, type->sizeof_nkey);
+ new_bt->ndirty = 2;
+ new_bt->level = level + 1;
+ new_bt->nchildren = 2;
+
+ new_bt->child[0] = old_root;
+ new_bt->key[0].dirty = TRUE;
+ new_bt->key[0].nkey = new_bt->native;
+ HDmemcpy(new_bt->key[0].nkey, lt_key, type->sizeof_nkey);
+
+ new_bt->child[1] = child;
+ new_bt->key[1].dirty = TRUE;
+ new_bt->key[1].nkey = new_bt->native + type->sizeof_nkey;
+ HDmemcpy(new_bt->key[1].nkey, md_key, type->sizeof_nkey);
+
+ new_bt->key[2].dirty = TRUE;
+ new_bt->key[2].nkey = new_bt->native + 2 * type->sizeof_nkey;
+ HDmemcpy(new_bt->key[2].nkey, rt_key, type->sizeof_nkey);
+
+ /* Insert the modified copy of the old root into the file again */
+ if (H5AC_set(f, dxpl_id, H5AC_BT, addr, new_bt) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to flush old B-tree root node")
#ifdef H5B_DEBUG
H5B_assert(f, dxpl_id, addr, type, udata);
@@ -1769,6 +1775,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
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")
+ sibling=NULL; /* Make certain future references will be caught */
}
if (H5F_addr_defined(bt->right)) {
if (NULL == (sibling = H5AC_protect(f, dxpl_id, H5AC_BT, bt->right, type, udata)))
@@ -1779,6 +1786,7 @@ H5B_remove_helper(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type
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")
+ sibling=NULL; /* Make certain future references will be caught */
}
bt->left = HADDR_UNDEF;
bt->right = HADDR_UNDEF;
@@ -1942,6 +1950,7 @@ 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")
+ bt=NULL; /* Make certain future references will be caught */
#ifdef H5B_DEBUG
H5B_assert(f, dxpl_id, addr, type, udata);
@@ -2022,6 +2031,7 @@ H5B_delete(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void
/* Release node in metadata cache */
if (H5AC_unprotect(f, dxpl_id, H5AC_BT, addr, bt, TRUE)<0)
HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node in cache")
+ bt=NULL; /* Make certain future references will be caught */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2394,6 +2404,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void
/* Release node */
status = H5AC_unprotect(f, dxpl_id, H5AC_BT, cur->addr, bt, FALSE);
assert(status >= 0);
+ bt=NULL; /* Make certain future references will be caught */
/* Advance current location in queue */
prev = cur;
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index d70a5c0..423ed57 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1009,8 +1009,9 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void UNUSED *_lt_key,
}
}
- if (snrt && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, *new_node_p, snrt, FALSE) != SUCCEED)
+ 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");
+ snrt=NULL; /* Make certain future references will be caught */
} else {
/* Where to insert the new entry? */
ret_value = H5B_INS_NOOP;
@@ -1289,6 +1290,7 @@ H5G_node_iterate (H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
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;
+ sn=NULL; /* Make certain future references will be caught */
/*
* Iterate over the symbol table node entries.
@@ -1361,6 +1363,7 @@ H5G_node_sumup(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
if (NULL == (sn = H5AC_find(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;
+ sn=NULL; /* Make certain future references will be caught */
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -1418,6 +1421,7 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
}
bt_udata->num_objs += sn->nsyms;
+ sn=NULL; /* Make certain future references will be caught */
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -1466,6 +1470,7 @@ H5G_node_type(H5F_t *f, hid_t dxpl_id, void UNUSED *_lt_key, haddr_t addr,
}
bt_udata->num_objs += sn->nsyms;
+ sn=NULL; /* Make certain future references will be caught */
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5HG.c b/src/H5HG.c
index 559bc1c..4c81a93 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -786,6 +786,7 @@ H5HG_peek (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
}
}
}
+ heap=NULL;
done:
FUNC_LEAVE_NOAPI(ret_value);
@@ -853,6 +854,7 @@ H5HG_read (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj, void *object/*out*/)
}
}
}
+ heap = NULL;
/* Set return value */
ret_value=object;
@@ -943,6 +945,7 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
size_t need;
int i;
unsigned u;
+ hbool_t deleted=FALSE; /* Whether the heap gets deleted */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HG_remove, FAIL);
@@ -995,11 +998,11 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
heap->cache_info.dirty = FALSE;
H5_CHECK_OVERFLOW(heap->size,size_t,hsize_t);
H5MF_xfree(f, H5FD_MEM_GHEAP, dxpl_id, heap->addr, (hsize_t)heap->size);
- H5AC_flush (f, dxpl_id, H5AC_GHEAP, heap->addr, H5F_FLUSH_INVALIDATE);
+ deleted=TRUE; /* Indicate that the object was deleted, for the unprotect call */
} else {
/*
* If the heap is in the CWFS list then advance it one position. The
- * H5AC_find() might have done that too, but that's okay. If the
+ * H5AC_protect() might have done that too, but that's okay. If the
* heap isn't on the CWFS list then add it to the end.
*/
for (i=0; i<f->shared->ncwfs; i++) {
@@ -1017,9 +1020,9 @@ H5HG_remove (H5F_t *f, hid_t dxpl_id, H5HG_t *hobj)
}
}
- if (H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, FALSE) != SUCCEED)
+done:
+ if (heap && H5AC_unprotect(f, dxpl_id, H5AC_GHEAP, hobj->addr, heap, deleted) != SUCCEED)
HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header");
-done:
FUNC_LEAVE_NOAPI(ret_value);
}
diff --git a/src/H5HL.c b/src/H5HL.c
index 81c5d88..e4044cb 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -637,6 +637,7 @@ H5HL_read(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size, voi
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);
+ heap=NULL;
/* Set return value */
ret_value=buf;
@@ -696,6 +697,7 @@ H5HL_peek(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset)
/* Set return value */
ret_value = heap->chunk + H5HL_SIZEOF_HDR(f) + offset;
+ heap=NULL;
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5O.c b/src/H5O.c
index 17ca3a1..e34f750 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1339,6 +1339,7 @@ H5O_count_real (H5G_entry_t *ent, const H5O_class_t *type, hid_t dxpl_id)
if (oh->mesg[u].type==type)
acc++;
}
+ oh=NULL;
/* Set return value */
ret_value=acc;
@@ -1441,6 +1442,7 @@ H5O_exists_real(H5G_entry_t *ent, const H5O_class_t *type, int sequence, hid_t d
if (--sequence<0)
break;
}
+ oh=NULL;
/* Set return value */
ret_value=(sequence<0);