33 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44 * University Research and Technology
55 * Corporation. All rights reserved.
6- * Copyright (c) 2004-2014 The University of Tennessee and The University
6+ * Copyright (c) 2004-2015 The University of Tennessee and The University
77 * of Tennessee Research Foundation. All rights
88 * reserved.
99 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
2929#include "ompi/peruse/peruse-internal.h"
3030#include "ompi/message/message.h"
3131
32+ /**
33+ * Single usage request. As we allow recursive calls to recv
34+ * (from the request completion callback), we cannot rely on
35+ * using a global request. Thus, once a recv acquires ownership
36+ * this global request, it should set it to NULL to prevent
37+ * the reuse until the first user completes.
38+ */
3239mca_pml_ob1_recv_request_t * mca_pml_ob1_recvreq = NULL ;
3340
3441int mca_pml_ob1_irecv_init (void * addr ,
@@ -96,15 +103,13 @@ int mca_pml_ob1_recv(void *addr,
96103
97104#if !OMPI_ENABLE_THREAD_MULTIPLE
98105 recvreq = mca_pml_ob1_recvreq ;
106+ mca_pml_ob1_recvreq = NULL ;
99107 if ( OPAL_UNLIKELY (NULL == recvreq ) )
100108#endif /* !OMPI_ENABLE_THREAD_MULTIPLE */
101109 {
102110 MCA_PML_OB1_RECV_REQUEST_ALLOC (recvreq );
103111 if (NULL == recvreq )
104112 return OMPI_ERR_TEMP_OUT_OF_RESOURCE ;
105- #if !OMPI_ENABLE_THREAD_MULTIPLE
106- mca_pml_ob1_recvreq = recvreq ;
107- #endif /* !OMPI_ENABLE_THREAD_MULTIPLE */
108113 }
109114
110115 MCA_PML_OB1_RECV_REQUEST_INIT (recvreq , addr , count , datatype ,
@@ -126,7 +131,12 @@ int mca_pml_ob1_recv(void *addr,
126131#if OMPI_ENABLE_THREAD_MULTIPLE
127132 MCA_PML_OB1_RECV_REQUEST_RETURN (recvreq );
128133#else
129- mca_pml_ob1_recv_request_fini (recvreq );
134+ if ( NULL != mca_pml_ob1_recvreq ) {
135+ MCA_PML_OB1_RECV_REQUEST_RETURN (recvreq );
136+ } else {
137+ mca_pml_ob1_recv_request_fini (recvreq );
138+ mca_pml_ob1_recvreq = recvreq ;
139+ }
130140#endif
131141
132142 return rc ;
0 commit comments