Skip to content

Commit

Permalink
Propagate the error up to the user.
Browse files Browse the repository at this point in the history
Make sure to reset the generalized request to guarantee not to call the
free callback a second time.

Signed-off-by: George Bosilca <[email protected]>
  • Loading branch information
bosilca committed May 16, 2023
1 parent 5ea8638 commit a67ac80
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions ompi/request/grequest.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,36 @@
*/
static int ompi_grequest_free(ompi_request_t** req)
{
OBJ_RELEASE(*req);
*req = MPI_REQUEST_NULL;
return OMPI_SUCCESS;
ompi_grequest_t* greq = (ompi_grequest_t*)*req;
int rc = OMPI_SUCCESS;

if (NULL != greq->greq_free.c_free) {
/* We were already putting query_fn()'s return value into
* status.MPI_ERROR but for MPI_{Wait,Test}*. If there's a
* free callback to invoke, the standard says to use the
* return value from free_fn() callback, too.
*/
if (greq->greq_funcs_are_c) {
greq->greq_base.req_status.MPI_ERROR =
greq->greq_free.c_free(greq->greq_state);
} else {
MPI_Fint ierr;
greq->greq_free.f_free((MPI_Aint*)greq->greq_state, &ierr);
greq->greq_base.req_status.MPI_ERROR =
OMPI_FINT_2_INT(ierr);
}
rc = greq->greq_base.req_status.MPI_ERROR;
}
if (OMPI_SUCCESS == rc ) {
OBJ_RELEASE(*req);
*req = MPI_REQUEST_NULL;
} else {
/* Make sure we will not be calling the grequest free function
* a second time when we release the request.
*/
greq->greq_free.c_free = NULL;
}
return rc;
}

static int ompi_grequest_cancel(ompi_request_t* req, int flag)
Expand Down Expand Up @@ -122,23 +149,6 @@ static void ompi_grequest_construct(ompi_grequest_t* greq)
*/
static void ompi_grequest_destruct(ompi_grequest_t* greq)
{
if (greq->greq_free.c_free != NULL) {
/* We were already putting query_fn()'s return value into
* status.MPI_ERROR but for MPI_{Wait,Test}*. If there's a
* free callback to invoke, the standard says to use the
* return value from free_fn() callback, too.
*/
if (greq->greq_funcs_are_c) {
greq->greq_base.req_status.MPI_ERROR =
greq->greq_free.c_free(greq->greq_state);
} else {
MPI_Fint ierr;
greq->greq_free.f_free((MPI_Aint*)greq->greq_state, &ierr);
greq->greq_base.req_status.MPI_ERROR =
OMPI_FINT_2_INT(ierr);
}
}

OMPI_REQUEST_FINI(&greq->greq_base);
}

Expand Down

0 comments on commit a67ac80

Please sign in to comment.