summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2013-08-29 13:54:05 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2013-08-29 13:54:05 (GMT)
commitb254caea6c838b448460db5d4b3985fecf6ead97 (patch)
treeccd20872875560ce3c4d04d9ba906f63c9e7d536
parent6d1b20cf3c2689e4d8d3d3bcd42be9cf3591789d (diff)
downloadhdf5-b254caea6c838b448460db5d4b3985fecf6ead97.zip
hdf5-b254caea6c838b448460db5d4b3985fecf6ead97.tar.gz
hdf5-b254caea6c838b448460db5d4b3985fecf6ead97.tar.bz2
[svn-r24085] Add a common routine to decrement ref count on a request and free if ref count reaches 0.
-rw-r--r--src/H5VLiod.c69
-rw-r--r--src/H5VLiod_client.c24
-rw-r--r--src/H5VLiod_client.h12
3 files changed, 32 insertions, 73 deletions
diff --git a/src/H5VLiod.c b/src/H5VLiod.c
index f084a19..f0a1e20 100644
--- a/src/H5VLiod.c
+++ b/src/H5VLiod.c
@@ -363,12 +363,7 @@ H5VL__iod_request_remove_from_axe_list(H5VL_iod_request_t *request)
request->global_prev = NULL;
request->global_next = NULL;
- request->rc --;
-
- if(0 == request->rc) {
- request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
- request = (H5VL_iod_request_t *)H5MM_xfree(request);
- }
+ H5VL_iod_request_decr_rc(request);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5VL__iod_request_remove_from_axe_list() */
@@ -513,7 +508,7 @@ H5VL__iod_create_and_forward(hg_id_t op_id, H5RQ_type_t op_type,
if(H5VL_iod_request_wait(request_obj->file, request) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't wait on HG request");
- request->rc --;
+ H5VL_iod_request_decr_rc(request);
request->req = H5MM_xfree(request->req);
HDassert(1 == request->rc);
@@ -6213,19 +6208,13 @@ H5VL_iod_cancel(void **req, H5_status_t *status)
if(H5VL_iod_request_complete(request->obj->file, request) < 0)
fprintf(stderr, "Operation Failed!\n");
- /* decrement the ref count on the actual request */
- request->rc --;
-
*status = request->status;
/* free the mercury request */
request->req = H5MM_xfree(request->req);
- /* free the actual request if the ref count reached 0 */
- if(0 == request->rc) {
- request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
- request = (H5VL_iod_request_t *)H5MM_xfree(request);
- }
+ /* Decrement ref count on request */
+ H5VL_iod_request_decr_rc(request);
}
/* forward the cancel call to the IONs */
@@ -6249,19 +6238,13 @@ H5VL_iod_cancel(void **req, H5_status_t *status)
HDONE_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to wait for request");
}
- /* decrement the ref count on the actual request */
- request->rc --;
-
*status = request->status;
/* free the mercury request */
request->req = H5MM_xfree(request->req);
- /* free the actual request if the ref count reached 0 */
- if(0 == request->rc) {
- request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
- request = (H5VL_iod_request_t *)H5MM_xfree(request);
- }
+ /* Decrement ref count on request */
+ H5VL_iod_request_decr_rc(request);
}
/* if the status returned is cancelled, then cancel it
@@ -6272,19 +6255,13 @@ H5VL_iod_cancel(void **req, H5_status_t *status)
if(H5VL_iod_request_cancel(request->obj->file, request) < 0)
fprintf(stderr, "Operation Failed!\n");
- /* decrement the ref count on the actual request */
- request->rc --;
-
*status = request->status;
/* free the mercury request */
request->req = H5MM_xfree(request->req);
- /* free the actual request if the ref count reached 0 */
- if(0 == request->rc) {
- request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
- request = (H5VL_iod_request_t *)H5MM_xfree(request);
- }
+ /* Decrement ref count on request */
+ H5VL_iod_request_decr_rc(request);
}
}
else
@@ -6327,17 +6304,11 @@ H5VL_iod_test(void **req, H5_status_t *status)
/* remove the request from the file linked list */
H5VL_iod_request_delete(request->obj->file, request);
- /* decrement the ref count on the actual request */
- request->rc --;
-
/* free the mercury request */
request->req = H5MM_xfree(request->req);
- /* free the actual request if the ref count reached 0 */
- if(0 == request->rc) {
- request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
- request = (H5VL_iod_request_t *)H5MM_xfree(request);
- }
+ /* Decrement ref count on request */
+ H5VL_iod_request_decr_rc(request);
}
else {
if(hg_status) {
@@ -6348,19 +6319,13 @@ H5VL_iod_test(void **req, H5_status_t *status)
if(H5VL_iod_request_complete(request->obj->file, request) < 0)
fprintf(stderr, "Operation Failed!\n");
- /* decrement the ref count on the actual request */
- request->rc --;
-
*status = request->status;
/* free the mercury request */
request->req = H5MM_xfree(request->req);
- /* free the actual request if the ref count reached 0 */
- if(0 == request->rc) {
- request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
- request = (H5VL_iod_request_t *)H5MM_xfree(request);
- }
+ /* Decrement ref count on request */
+ H5VL_iod_request_decr_rc(request);
}
/* request has not finished, set return status appropriately */
else
@@ -6398,19 +6363,13 @@ H5VL_iod_wait(void **req, H5_status_t *status)
HGOTO_ERROR(H5E_SYM, H5E_CANTFREE, FAIL, "unable to wait for request")
}
- /* decrement the ref count on the actual request */
- request->rc --;
-
*status = request->status;
/* free the mercury request */
request->req = H5MM_xfree(request->req);
- /* free the actual request if the ref count reached 0 */
- if(0 == request->rc) {
- request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
- request = (H5VL_iod_request_t *)H5MM_xfree(request);
- }
+ /* Decrement ref count on request */
+ H5VL_iod_request_decr_rc(request);
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5VLiod_client.c b/src/H5VLiod_client.c
index d81034e..74db59b 100644
--- a/src/H5VLiod_client.c
+++ b/src/H5VLiod_client.c
@@ -60,6 +60,21 @@ static herr_t H5VL__iod_pre_write_cb(void UNUSED *elem, hid_t type_id, unsigned
static herr_t H5VL__iod_vl_read_finalize(size_t buf_size, void *read_buf, void *user_buf,
H5S_t *mem_space, hid_t mem_type_id, hid_t dset_type_id);
+herr_t
+H5VL_iod_request_decr_rc(H5VL_iod_request_t *request)
+{
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ request->rc --;
+
+ if(0 == request->rc) {
+ request->parent_reqs = (H5VL_iod_request_t **)H5MM_xfree(request->parent_reqs);
+ request = (H5VL_iod_request_t *)H5MM_xfree(request);
+ }
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+}
+
/*-------------------------------------------------------------------------
* Function: H5VL_iod_request_add
@@ -119,13 +134,8 @@ H5VL_iod_request_delete(H5VL_iod_file_t *file, H5VL_iod_request_t *request)
/* decrement ref count on parent requests */
for(u=0 ; u<request->num_parents ; u++) {
- request->parent_reqs[u]->rc --;
- if(0 == request->parent_reqs[u]->rc) {
- request->parent_reqs[u]->parent_reqs = (H5VL_iod_request_t **)
- H5MM_xfree(request->parent_reqs[u]->parent_reqs);
- request->parent_reqs[u] = (H5VL_iod_request_t *)
- H5MM_xfree(request->parent_reqs[u]);
- }
+ /* Decrement ref count on request */
+ H5VL_iod_request_decr_rc(request->parent_reqs[u]);
}
prev = request->prev;
diff --git a/src/H5VLiod_client.h b/src/H5VLiod_client.h
index b8b9257..a3e34df 100644
--- a/src/H5VLiod_client.h
+++ b/src/H5VLiod_client.h
@@ -259,6 +259,7 @@ H5_DLL herr_t H5VL_iod_request_wait_all(H5VL_iod_file_t *file);
H5_DLL herr_t H5VL_iod_request_wait_some(H5VL_iod_file_t *file, const void *object);
H5_DLL herr_t H5VL_iod_request_complete(H5VL_iod_file_t *file, H5VL_iod_request_t *req);
H5_DLL herr_t H5VL_iod_request_cancel(H5VL_iod_file_t *file, H5VL_iod_request_t *req);
+H5_DLL herr_t H5VL_iod_request_decr_rc(H5VL_iod_request_t *request);
H5_DLL herr_t H5VL_iod_get_parent_info(H5VL_iod_object_t *obj, H5VL_loc_params_t loc_params,
const char *name, /*OUT*/iod_obj_id_t *iod_id,
@@ -272,17 +273,6 @@ H5_DLL herr_t H5VL__iod_create_and_forward(hg_id_t op_id, H5RQ_type_t op_type,
H5VL_iod_object_t *request_obj, htri_t track,
size_t num_parents, H5VL_iod_request_t **parent_reqs,
void *input, void *output, void *data, void **req);
-/*
-H5_DLL herr_t H5VL__iod_create_and_forward(hg_id_t op_id, H5RQ_type_t op_type,
- H5VL_iod_object_t *request_obj, htri_t track,
- void *input, void *output, void *data, void **req);
-H5_DLL herr_t H5VL_iod_get_parent_info(H5VL_iod_object_t *obj, H5VL_loc_params_t loc_params,
- const char *name, iod_obj_id_t *iod_id, iod_handle_t *iod_oh,
- uint64_t *axe_id, char **new_name,
- H5VL_iod_object_t **last_obj);
-H5_DLL herr_t H5VL_iod_get_axe_parents(H5VL_iod_object_t *obj, size_t *count,
- uint64_t *parents);
-*/
H5_DLL herr_t H5VL_iod_gen_obj_id(int myrank, int nranks, uint64_t cur_index,
iod_obj_type_t type, uint64_t *id);