diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-20 20:10:44 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-04-20 20:10:44 (GMT) |
commit | 59941cf993ca2bd0c02e028a7fe68bf489a1ee65 (patch) | |
tree | c25b10ce5465f324e495147f0bc024cac7119ac6 /src/H5Ochunk.c | |
parent | a2ad2f1b2af028af44c6304dde6092676d4b4c92 (diff) | |
download | hdf5-59941cf993ca2bd0c02e028a7fe68bf489a1ee65.zip hdf5-59941cf993ca2bd0c02e028a7fe68bf489a1ee65.tar.gz hdf5-59941cf993ca2bd0c02e028a7fe68bf489a1ee65.tar.bz2 |
[svn-r18600] Description:
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:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
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 */ |