summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-07-30 18:53:01 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-07-30 18:53:01 (GMT)
commit0c9c34fab681a559633cbae215cb49ca812f4a3d (patch)
treeea192413d801b0a9d550172ca3e8f8d7771f3659 /src
parentddb2af421f244dd92e8d7f53a1bb2b9a9df14bde (diff)
downloadhdf5-0c9c34fab681a559633cbae215cb49ca812f4a3d.zip
hdf5-0c9c34fab681a559633cbae215cb49ca812f4a3d.tar.gz
hdf5-0c9c34fab681a559633cbae215cb49ca812f4a3d.tar.bz2
[svn-r11176] Purpose:
Bug fix Description: Correct problems when querying information about a group that was opened by dereferencing an object reference. Solution: Read in symbol table information instead of rely on it being cached. Platforms tested: FreeBSD 4.11 (sleipnir) Too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r--src/H5G.c69
-rw-r--r--src/H5Gnode.c4
-rw-r--r--src/H5Gpkg.h3
3 files changed, 29 insertions, 47 deletions
diff --git a/src/H5G.c b/src/H5G.c
index c2305c5..d1c5ac9 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -104,7 +104,6 @@
#include "H5HLprivate.h" /* Local Heaps */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
-#include "H5Oprivate.h" /* Object headers */
#include "H5Pprivate.h" /* Property lists */
/* Local macros */
@@ -592,11 +591,8 @@ ssize_t
H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size)
{
H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */
-#ifdef OLD_WAY
- hsize_t num_objs;
-#endif /* OLD_WAY */
ssize_t ret_value = FAIL;
-
+
FUNC_ENTER_API(H5Gget_objname_by_idx, FAIL);
H5TRACE4("Zs","ihsz",loc_id,idx,name,size);
@@ -605,19 +601,7 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size)
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID");
if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP)
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
-
-#ifdef OLD_WAY
-/* Don't check for the number of objects in the group currently, because this
- * has to iterate through the group in order to find out the information.
- * We might as well just iterate through all the group entries and error out
- * if we didn't find the index we are looking for. -QAK
- */
- if (H5G_get_num_objs(loc, &num_objs, H5AC_ind_dxpl_id)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to retrieve number of members");
- if(idx >= num_objs)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "index out of bound");
-#endif /* OLD_WAY */
-
+
/*call private function*/
ret_value = H5G_get_objname_by_idx(loc, idx, name, size, H5AC_ind_dxpl_id);
@@ -647,9 +631,6 @@ H5G_obj_t
H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx)
{
H5G_entry_t *loc = NULL; /* Pointer to symbol table entry */
-#ifdef OLD_WAY
- hsize_t num_objs;
-#endif /* OLD_WAY */
H5G_obj_t ret_value;
FUNC_ENTER_API(H5Gget_objtype_by_idx, H5G_UNKNOWN);
@@ -660,19 +641,7 @@ H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx)
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID");
if(H5G_get_type(loc,H5AC_ind_dxpl_id)!=H5G_GROUP)
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a group");
-
-#ifdef OLD_WAY
-/* Don't check for the number of objects in the group currently, because this
- * has to iterate through the group in order to find out the information.
- * We might as well just iterate through all the group entries and error out
- * if we didn't find the index we are looking for. -QAK
- */
- if (H5G_get_num_objs(loc, &num_objs, H5AC_ind_dxpl_id)<0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "unable to retrieve number of members");
- if(idx >= num_objs)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "index out of bound");
-#endif /* OLD_WAY */
-
+
/*call private function*/
ret_value = H5G_get_objtype_by_idx(loc, idx, H5AC_ind_dxpl_id);
@@ -2912,21 +2881,25 @@ done:
static herr_t
H5G_get_num_objs(H5G_entry_t *loc, hsize_t *num_objs, hid_t dxpl_id)
{
+ H5O_stab_t stab_mesg; /*info about B-tree */
herr_t ret_value;
FUNC_ENTER_NOAPI(H5G_get_num_objs, FAIL);
/* Sanity check */
assert(loc);
- assert(loc->type==H5G_CACHED_STAB);
assert(num_objs);
/* Reset the number of objects in the group */
*num_objs = 0;
+ /* Get the B-tree info */
+ if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id))
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address");
+
/* Iterate over the group members */
if ((ret_value = H5B_iterate (loc->file, dxpl_id, H5B_SNODE,
- H5G_node_sumup, loc->cache.stab.btree_addr, num_objs))<0)
+ H5G_node_sumup, stab_mesg.btree_addr, num_objs))<0)
HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
done:
@@ -2954,6 +2927,7 @@ done:
static ssize_t
H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, hid_t dxpl_id)
{
+ H5O_stab_t stab_mesg; /*info about local heap & B-tree */
H5G_bt_ud3_t udata; /* Iteration information */
ssize_t ret_value; /* Return value */
@@ -2961,17 +2935,20 @@ H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, h
/* Sanity check */
assert(loc);
- assert(loc->type==H5G_CACHED_STAB);
+
+ /* Get the B-tree & local heap info */
+ if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id))
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address");
/* Set iteration information */
udata.idx = idx;
udata.num_objs = 0;
- udata.ent = loc;
+ udata.mesg = &stab_mesg;
udata.name = NULL;
/* Iterate over the group members */
if ((ret_value = H5B_iterate (loc->file, dxpl_id, H5B_SNODE,
- H5G_node_name, loc->cache.stab.btree_addr, &udata))<0)
+ H5G_node_name, stab_mesg.btree_addr, &udata))<0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "iteration operator failed");
/* If we don't know the name now, we almost certainly went out of bounds */
@@ -3016,24 +2993,28 @@ done:
static H5G_obj_t
H5G_get_objtype_by_idx(H5G_entry_t *loc, hsize_t idx, hid_t dxpl_id)
{
- H5G_bt_ud3_t udata; /* User data for B-tree callback */
- H5G_obj_t ret_value; /* Return value */
+ H5O_stab_t stab_mesg; /*info about local heap & B-tree */
+ H5G_bt_ud3_t udata; /* User data for B-tree callback */
+ H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_get_objtype_by_idx, H5G_UNKNOWN);
/* Sanity check */
assert(loc);
- assert(loc->type==H5G_CACHED_STAB);
+
+ /* Get the B-tree & local heap info */
+ if (NULL==H5O_read (loc, H5O_STAB_ID, 0, &stab_mesg, dxpl_id))
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address");
/* Set iteration information */
udata.idx = idx;
udata.num_objs = 0;
- udata.ent = loc;
+ udata.mesg = &stab_mesg;
udata.type = H5G_UNKNOWN;
/* Iterate over the group members */
if (H5B_iterate (loc->file, dxpl_id, H5B_SNODE,
- H5G_node_type, loc->cache.stab.btree_addr, &udata)<0)
+ H5G_node_type, stab_mesg.btree_addr, &udata)<0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "iteration operator failed");
/* If we don't know the type now, we almost certainly went out of bounds */
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index f88c89c..dfa607e 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1679,7 +1679,7 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
loc_idx = bt_udata->idx - bt_udata->num_objs;
name_off = sn->entry[loc_idx].name_off;
- if (NULL == (heap = H5HL_protect(f, dxpl_id, bt_udata->ent->cache.stab.heap_addr)))
+ if (NULL == (heap = H5HL_protect(f, dxpl_id, bt_udata->mesg->heap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_ITER_ERROR, "unable to protect symbol name");
name = H5HL_offset_into(f, heap, name_off);
@@ -1687,7 +1687,7 @@ H5G_node_name(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr,
bt_udata->name = H5MM_strdup (name);
assert(bt_udata->name);
- if (H5HL_unprotect(f, dxpl_id, heap, bt_udata->ent->cache.stab.heap_addr, H5AC__NO_FLAGS_SET) < 0)
+ if (H5HL_unprotect(f, dxpl_id, heap, bt_udata->mesg->heap_addr, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_ITER_ERROR, "unable to unprotect symbol name");
heap=NULL; name=NULL;
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 36a18f9..f970b2d 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -32,6 +32,7 @@
/* Other private headers needed by this file */
#include "H5ACprivate.h" /* Metadata cache */
+#include "H5Oprivate.h" /* Object headers */
/*
* A symbol table node is a collection of symbol table entries. It can
@@ -113,7 +114,7 @@ typedef struct H5G_bt_ud2_t {
*/
typedef struct H5G_bt_ud3_t {
/* downward */
- H5G_entry_t *ent; /*the entry of group being queried */
+ const H5O_stab_t *mesg; /*the symbol table message of group being queried */
hsize_t idx; /*index of group member to be queried */
hsize_t num_objs; /*the number of objects having been traversed*/