diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-20 20:21:24 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-20 20:21:24 (GMT) |
commit | ef3d6fc8dda3ad44c493ed8e372ca9ede5a096df (patch) | |
tree | 10bbf3058e630411def78a5cd653aa4d7e989fbf /src/H5Ochunk.c | |
parent | 64af76ef7d19f9377c04c46a52f0175e8336dfb8 (diff) | |
download | hdf5-ef3d6fc8dda3ad44c493ed8e372ca9ede5a096df.zip hdf5-ef3d6fc8dda3ad44c493ed8e372ca9ede5a096df.tar.gz hdf5-ef3d6fc8dda3ad44c493ed8e372ca9ede5a096df.tar.bz2 |
[svn-r18602] Description:
Bring r18600 from trunk to 1.8 branch:
Increment reference count on object header when "fake" object header
chunk proxy is returned from H5O_chunk_protect(). Also, clean up the
interface to H5O_chunk_unprotect by removing the unnecessary 'oh' parameter.
Tested on:
Mac OS X/32 10.6.3 (amazon) w/debug
(h5committested on trunk)
Diffstat (limited to 'src/H5Ochunk.c')
-rw-r--r-- | src/H5Ochunk.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/H5Ochunk.c b/src/H5Ochunk.c index 59102b6..03865fb 100644 --- a/src/H5Ochunk.c +++ b/src/H5Ochunk.c @@ -161,6 +161,10 @@ H5O_chunk_protect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned idx) if(NULL == (chk_proxy = H5FL_CALLOC(H5O_chunk_proxy_t))) HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, NULL, "memory allocation failed") + /* Increment reference count on object header */ + if(H5O_inc_rc(oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINC, NULL, "can't increment reference count on object header") + /* Set chunk proxy fields */ chk_proxy->oh = oh; chk_proxy->chunkno = idx; @@ -207,7 +211,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_chunk_proxy_t *chk_proxy, +H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_chunk_proxy_t *chk_proxy, unsigned chk_flags) { herr_t ret_value = SUCCEED; /* Return value */ @@ -216,7 +220,6 @@ H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_chunk_proxy_t *chk_p /* check args */ HDassert(f); - HDassert(oh); HDassert(chk_proxy); HDassert(!(chk_flags & (unsigned)~(H5AC__DIRTIED_FLAG | H5AC__SIZE_CHANGED_FLAG))); @@ -225,13 +228,13 @@ H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_chunk_proxy_t *chk_p /* Check for resizing the first chunk */ if(chk_flags & H5AC__SIZE_CHANGED_FLAG) { /* Resize object header in cache */ - if(H5AC_resize_pinned_entry(oh, oh->chunk[0].size) < 0) + if(H5AC_resize_pinned_entry(chk_proxy->oh, chk_proxy->oh->chunk[0].size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTRESIZE, FAIL, "unable to resize chunk in cache") } /* end if */ /* Check for dirtying the first chunk */ else if(chk_flags & H5AC__DIRTIED_FLAG) { /* Mark object header as dirty in cache */ - if(H5AC_mark_pinned_or_protected_entry_dirty(oh) < 0) + if(H5AC_mark_pinned_or_protected_entry_dirty(chk_proxy->oh) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTMARKDIRTY, FAIL, "unable to mark object header as dirty") } /* end else/if */ else { @@ -239,12 +242,16 @@ H5O_chunk_unprotect(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_chunk_proxy_t *chk_p HDassert(0 && "Unknown chunk proxy flag(s)?!?"); } /* end else */ + /* Decrement reference count of object header */ + if(H5O_dec_rc(chk_proxy->oh) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTDEC, FAIL, "can't decrement reference count on object header") + /* Free fake chunk proxy */ chk_proxy = H5FL_FREE(H5O_chunk_proxy_t, chk_proxy); } /* end if */ else { /* Release the chunk proxy from the cache, marking it dirty */ - if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_CHK, oh->chunk[chk_proxy->chunkno].addr, chk_proxy, chk_flags) < 0) + if(H5AC_unprotect(f, dxpl_id, H5AC_OHDR_CHK, chk_proxy->oh->chunk[chk_proxy->chunkno].addr, chk_proxy, chk_flags) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header chunk") } /* end else */ |