|
9 | 9 | * University of Stuttgart. All rights reserved.
|
10 | 10 | * Copyright (c) 2004-2005 The Regents of the University of California.
|
11 | 11 | * All rights reserved.
|
12 |
| - * Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved. |
| 12 | + * Copyright (c) 2006-2021 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,13 +122,20 @@ static void ompi_grequest_construct(ompi_grequest_t* greq)
|
121 | 122 | */
|
122 | 123 | static void ompi_grequest_destruct(ompi_grequest_t* greq)
|
123 | 124 | {
|
124 |
| - MPI_Fint ierr; |
125 |
| - |
126 | 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 | + */ |
127 | 131 | if (greq->greq_funcs_are_c) {
|
128 |
| - greq->greq_free.c_free(greq->greq_state); |
| 132 | + greq->greq_base.req_status.MPI_ERROR = |
| 133 | + greq->greq_free.c_free(greq->greq_state); |
129 | 134 | } else {
|
| 135 | + MPI_Fint ierr; |
130 | 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); |
131 | 139 | }
|
132 | 140 | }
|
133 | 141 |
|
@@ -214,8 +222,21 @@ int ompi_grequest_invoke_query(ompi_request_t *request,
|
214 | 222 | if (g->greq_funcs_are_c) {
|
215 | 223 | rc = g->greq_query.c_query(g->greq_state, status);
|
216 | 224 | } else {
|
| 225 | + /* request->req_status.MPI_ERROR was initialized to success |
| 226 | + * and it's meant to be unmodified in the case of callback |
| 227 | + * success, and set when callbacks return a failure. But |
| 228 | + * if we leave fstatus uninitialized this sets |
| 229 | + * req_status.MPI_ERROR to whatever happened to be on the |
| 230 | + * stack at fstatus (f_query isn't supposed to directly set |
| 231 | + * its status.MPI_ERROR, according to the standard) |
| 232 | + * |
| 233 | + * So the Status_c2f below only really cares about transferring |
| 234 | + * the MPI_ERROR setting into fstatus so that when it's transferred |
| 235 | + * back in the f2c call, it has the starting value. |
| 236 | + */ |
217 | 237 | MPI_Fint ierr;
|
218 | 238 | MPI_Fint fstatus[sizeof(MPI_Status) / sizeof(int)];
|
| 239 | + MPI_Status_c2f(status, fstatus); |
219 | 240 | g->greq_query.f_query((MPI_Aint*)g->greq_state, fstatus, &ierr);
|
220 | 241 | MPI_Status_f2c(fstatus, status);
|
221 | 242 | rc = OMPI_FINT_2_INT(ierr);
|
|
0 commit comments