diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-07-09 02:06:32 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-07-09 02:06:32 (GMT) |
commit | 6beaf50c8fc861e99b46500b4dc7f606e8f72ffb (patch) | |
tree | f718fce63e96ad19d5cb8aea628a4c4755918aa0 /src/H5B.c | |
parent | 9437a2686563bda04c9dda9e6c09bb527fe63dd0 (diff) | |
download | hdf5-6beaf50c8fc861e99b46500b4dc7f606e8f72ffb.zip hdf5-6beaf50c8fc861e99b46500b4dc7f606e8f72ffb.tar.gz hdf5-6beaf50c8fc861e99b46500b4dc7f606e8f72ffb.tar.bz2 |
[svn-r8846] Purpose:
Bug fix
Description:
The "shared" raw B-tree node can get freed before all the B-tree nodes
had been flushed out to disk and released by the cache.
Solution:
Implement a simple reference counting wrapper for objects in the library
and use it to hold the shared raw B-tree nodes so they aren't freed before all
references to them in memory are released.
Platforms tested:
Solaris 2.7 (arabica)
FreeBSD 4.10 (sleipnir)
IRIX64 6.5 (modei4)
Diffstat (limited to 'src/H5B.c')
-rw-r--r-- | src/H5B.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -243,8 +243,9 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, bt->left = HADDR_UNDEF; bt->right = HADDR_UNDEF; bt->nchildren = 0; - if((bt->raw_page=(type->get_page)(f, udata))==NULL) + if((bt->rc_page=(type->get_page)(f, udata))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer") + bt->raw_page=H5RC_GET_OBJ(bt->rc_page); if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,total_native_keysize)) || NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type)))) || NULL==(bt->nkey=H5FL_SEQ_MALLOC(voidp,(size_t)(2*H5F_KVALUE(f,type)+1)))) @@ -342,8 +343,9 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)(2*H5F_KVALUE(f,type))))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - if((bt->raw_page=(type->get_page)(f, udata))==NULL) + if((bt->rc_page=(type->get_page)(f, udata))==NULL) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "can't retrieve B-tree node buffer") + bt->raw_page=H5RC_GET_OBJ(bt->rc_page); if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->raw_page)<0) HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node") @@ -576,6 +578,7 @@ H5B_dest(H5F_t UNUSED *f, H5B_t *bt) H5FL_SEQ_FREE(haddr_t,bt->child); H5FL_SEQ_FREE(voidp,bt->nkey); H5FL_BLK_FREE(native_block,bt->native); + H5RC_DEC(bt->rc_page); H5FL_FREE(H5B_t,bt); FUNC_LEAVE_NOAPI(SUCCEED) @@ -2148,6 +2151,9 @@ H5B_copy(const H5F_t *f, const H5B_t *old_bt) new_node->nkey[u] = NULL; } + /* Increment the ref-count on the raw page */ + H5RC_INC(new_node->rc_page); + /* Set return value */ ret_value=new_node; |