Skip to content

Commit

Permalink
Modify nrefs directly to avoid closing conn with 0 refs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Jul 10, 2024
1 parent d318078 commit 2474cf9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/H5ES.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,19 @@ H5ESinsert_request(hid_t es_id, hid_t connector_id, void *request)
if (NULL == (connector = H5VL_new_connector(connector_id)))
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTCREATE, FAIL, "can't create VOL connector object");

/* Increment reference count above 0 so that connector can be closed if VOL object creation fails */
connector->nrefs++;

/* Insert request into event set */
if (H5ES__insert_request(es, connector, request) < 0)
HGOTO_ERROR(H5E_EVENTSET, H5E_CANTINSERT, FAIL, "can't insert request into event set");

connector->nrefs--;

done:
/* Clean up on error */
if (ret_value < 0)
/* Release newly created connector */
/* Release newly created connector.*/
if (connector && H5VL_conn_dec_rc(connector) < 0)
HDONE_ERROR(H5E_EVENTSET, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector");

Expand Down
3 changes: 2 additions & 1 deletion src/H5VLint.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,12 +982,13 @@ H5VL_conn_dec_rc(H5VL_t *connector)

/* Check arguments */
assert(connector);
assert(connector->nrefs >= 0);

/* Decrement refcount for connector */
connector->nrefs--;

/* Check for last reference */
if (0 >= connector->nrefs) {
if (0 == connector->nrefs) {
if (H5I_dec_ref(connector->id) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector");
H5FL_FREE(H5VL_t, connector);
Expand Down

0 comments on commit 2474cf9

Please sign in to comment.