Skip to content

Commit

Permalink
Decrement nrefs before raising error
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Jul 10, 2024
1 parent 12ae3ec commit 945246b
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/H5Oflush.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,10 @@ H5O__oh_tag(const H5O_loc_t *oloc, haddr_t *tag)
herr_t
H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid)
{
H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */
bool objs_incr = false; /* Whether the object count in the file was incremented */
H5F_t *file = NULL;
herr_t ret_value = SUCCEED; /* Return value */
bool conn_id_incr = false; /* Whether the VOL connector ID has been incremented */
H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */
bool objs_incr = false; /* Whether the object count in the file was incremented */
H5F_t *file = NULL;
herr_t ret_value = SUCCEED; /* Return value */

FUNC_ENTER_NOAPI(FAIL)

Expand Down Expand Up @@ -234,19 +233,21 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid)
* If you don't do this, VDS refreshes can accidentally close the connector.
*/
connector->nrefs++;
conn_id_incr = true;

/* Close object & evict its metadata */
if (H5O__refresh_metadata_close(oloc, &obj_loc, oid) < 0)
if (H5O__refresh_metadata_close(oloc, &obj_loc, oid) < 0) {
connector->nrefs--;
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object");
}

/* Re-open the object, re-fetching its metadata */
if (H5O_refresh_metadata_reopen(oid, H5P_DEFAULT, &obj_loc, connector, false) < 0)
if (H5O_refresh_metadata_reopen(oid, H5P_DEFAULT, &obj_loc, connector, false) < 0) {
connector->nrefs--;
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object");
}

/* Restore the number of references on the VOL connector */
connector->nrefs--;
conn_id_incr = false;

/* Restore important datatype state */
if (H5I_get_type(oid) == H5I_DATATYPE)
Expand All @@ -259,10 +260,6 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid)
if (objs_incr && file)
H5F_decr_nopen_objs(file);

if (vol_obj && vol_obj->connector)
if (conn_id_incr)
vol_obj->connector->nrefs--;

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O_refresh_metadata() */

Expand Down

0 comments on commit 945246b

Please sign in to comment.