|
11 | 11 | * All rights reserved.
|
12 | 12 | * Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
|
13 | 13 | * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
|
| 14 | + * Copyright (c) 2021 IBM Corporation. All rights reserved. |
14 | 15 | * $COPYRIGHT$
|
15 | 16 | *
|
16 | 17 | * Additional copyrights may follow
|
@@ -121,16 +122,24 @@ static void ompi_grequest_construct(ompi_grequest_t* greq)
|
121 | 122 | */
|
122 | 123 | static void ompi_grequest_destruct(ompi_grequest_t* greq)
|
123 | 124 | {
|
| 125 | + int rc; |
124 | 126 | MPI_Fint ierr;
|
125 | 127 |
|
126 | 128 | if (greq->greq_free.c_free != NULL) {
|
127 | 129 | if (greq->greq_funcs_are_c) {
|
128 |
| - greq->greq_free.c_free(greq->greq_state); |
| 130 | + rc = greq->greq_free.c_free(greq->greq_state); |
129 | 131 | } else {
|
130 | 132 | greq->greq_free.f_free((MPI_Aint*)greq->greq_state, &ierr);
|
| 133 | + rc = OMPI_FINT_2_INT(ierr); |
131 | 134 | }
|
132 | 135 | }
|
133 | 136 |
|
| 137 | + /* We were already putting query_fn()'s return value into |
| 138 | + * status.MPI_ERROR but for MPI_{Wait,Test}* the standard |
| 139 | + * says use the free_fn() callback too. |
| 140 | + */ |
| 141 | + greq->greq_base.req_status.MPI_ERROR = rc; |
| 142 | + |
134 | 143 | OMPI_REQUEST_FINI(&greq->greq_base);
|
135 | 144 | }
|
136 | 145 |
|
@@ -214,8 +223,21 @@ int ompi_grequest_invoke_query(ompi_request_t *request,
|
214 | 223 | if (g->greq_funcs_are_c) {
|
215 | 224 | rc = g->greq_query.c_query(g->greq_state, status);
|
216 | 225 | } else {
|
| 226 | + /* request->req_status.MPI_ERROR was initialized to success |
| 227 | + * and it's meant to be unmodified in the case of callback |
| 228 | + * success, and set when callbacks return a failure. But |
| 229 | + * if we leave fstatus uninitialized this sets |
| 230 | + * req_status.MPI_ERROR to whatever happened to be on the |
| 231 | + * stack at fstatus (f_query isn't supposed to directly set |
| 232 | + * its status.MPI_ERROR, according to the standard) |
| 233 | + * |
| 234 | + * So the Status_c2f below only really cares about transferring |
| 235 | + * the MPI_ERROR setting into fstatus so that when it's transferred |
| 236 | + * back in the f2c call, it has the starting value. |
| 237 | + */ |
217 | 238 | MPI_Fint ierr;
|
218 | 239 | MPI_Fint fstatus[sizeof(MPI_Status) / sizeof(int)];
|
| 240 | + MPI_Status_c2f(status, fstatus); |
219 | 241 | g->greq_query.f_query((MPI_Aint*)g->greq_state, fstatus, &ierr);
|
220 | 242 | MPI_Status_f2c(fstatus, status);
|
221 | 243 | rc = OMPI_FINT_2_INT(ierr);
|
|
0 commit comments