|
37 | 37 | */
|
38 | 38 | static int ompi_grequest_free(ompi_request_t** req)
|
39 | 39 | {
|
40 |
| - OBJ_RELEASE(*req); |
41 |
| - *req = MPI_REQUEST_NULL; |
42 |
| - return OMPI_SUCCESS; |
| 40 | + ompi_grequest_t* greq = (ompi_grequest_t*)*req; |
| 41 | + int rc = OMPI_SUCCESS; |
| 42 | + |
| 43 | + if (NULL != greq->greq_free.c_free) { |
| 44 | + /* We were already putting query_fn()'s return value into |
| 45 | + * status.MPI_ERROR but for MPI_{Wait,Test}*. If there's a |
| 46 | + * free callback to invoke, the standard says to use the |
| 47 | + * return value from free_fn() callback, too. |
| 48 | + */ |
| 49 | + if (greq->greq_funcs_are_c) { |
| 50 | + greq->greq_base.req_status.MPI_ERROR = |
| 51 | + greq->greq_free.c_free(greq->greq_state); |
| 52 | + } else { |
| 53 | + MPI_Fint ierr; |
| 54 | + greq->greq_free.f_free((MPI_Aint*)greq->greq_state, &ierr); |
| 55 | + greq->greq_base.req_status.MPI_ERROR = |
| 56 | + OMPI_FINT_2_INT(ierr); |
| 57 | + } |
| 58 | + rc = greq->greq_base.req_status.MPI_ERROR; |
| 59 | + } |
| 60 | + if (OMPI_SUCCESS == rc ) { |
| 61 | + OBJ_RELEASE(*req); |
| 62 | + *req = MPI_REQUEST_NULL; |
| 63 | + } else { |
| 64 | + /* Make sure we will not be calling the grequest free function |
| 65 | + * a second time when we release the request. |
| 66 | + */ |
| 67 | + greq->greq_free.c_free = NULL; |
| 68 | + } |
| 69 | + return rc; |
43 | 70 | }
|
44 | 71 |
|
45 | 72 | static int ompi_grequest_cancel(ompi_request_t* req, int flag)
|
@@ -122,23 +149,6 @@ static void ompi_grequest_construct(ompi_grequest_t* greq)
|
122 | 149 | */
|
123 | 150 | static void ompi_grequest_destruct(ompi_grequest_t* greq)
|
124 | 151 | {
|
125 |
| - if (greq->greq_free.c_free != NULL) { |
126 |
| - /* We were already putting query_fn()'s return value into |
127 |
| - * status.MPI_ERROR but for MPI_{Wait,Test}*. If there's a |
128 |
| - * free callback to invoke, the standard says to use the |
129 |
| - * return value from free_fn() callback, too. |
130 |
| - */ |
131 |
| - if (greq->greq_funcs_are_c) { |
132 |
| - greq->greq_base.req_status.MPI_ERROR = |
133 |
| - greq->greq_free.c_free(greq->greq_state); |
134 |
| - } else { |
135 |
| - MPI_Fint ierr; |
136 |
| - greq->greq_free.f_free((MPI_Aint*)greq->greq_state, &ierr); |
137 |
| - greq->greq_base.req_status.MPI_ERROR = |
138 |
| - OMPI_FINT_2_INT(ierr); |
139 |
| - } |
140 |
| - } |
141 |
| - |
142 | 152 | OMPI_REQUEST_FINI(&greq->greq_base);
|
143 | 153 | }
|
144 | 154 |
|
|
0 commit comments