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, 
1010 *                         University of Stuttgart.  All rights reserved. 
1111 * Copyright (c) 2004-2005 The Regents of the University of California. 
1212 *                         All rights reserved. 
13-  * Copyright (c) 2007-2014  Los Alamos National Security, LLC.  All rights 
13+  * Copyright (c) 2007-2015  Los Alamos National Security, LLC.  All rights 
1414 *                         reserved. 
1515 * Copyright (c) 2010-2012 Oracle and/or its affiliates.  All rights reserved. 
1616 * Copyright (c) 2011      Sandia National Laboratories. All rights reserved. 
2828#include  "pml_ob1_recvfrag.h" 
2929#include  "ompi/peruse/peruse-internal.h" 
3030#include  "ompi/message/message.h" 
31- #if  HAVE_ALLOCA_H 
32- #include  <alloca.h> 
33- #endif   /* HAVE_ALLOCA_H */ 
3431
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+  */ 
3539mca_pml_ob1_recv_request_t  * mca_pml_ob1_recvreq  =  NULL ;
3640
3741int  mca_pml_ob1_irecv_init (void  * addr ,
@@ -97,19 +101,16 @@ int mca_pml_ob1_recv(void *addr,
97101    mca_pml_ob1_recv_request_t  * recvreq  =  NULL ;
98102    int  rc ;
99103
100- #if  !OPAL_ENABLE_MULTI_THREADS 
104+ #if  !OMPI_ENABLE_THREAD_MULTIPLE 
101105    recvreq  =  mca_pml_ob1_recvreq ;
106+     mca_pml_ob1_recvreq  =  NULL ;
102107    if ( OPAL_UNLIKELY (NULL  ==  recvreq ) )
103- #endif   /* !OPAL_ENABLE_MULTI_THREADS  */ 
108+ #endif   /* !OMPI_ENABLE_THREAD_MULTIPLE  */ 
104109        {
105110            MCA_PML_OB1_RECV_REQUEST_ALLOC (recvreq );
106111            if  (NULL  ==  recvreq )
107112                return  OMPI_ERR_TEMP_OUT_OF_RESOURCE ;
108- #if  !OPAL_ENABLE_MULTI_THREADS 
109-             mca_pml_ob1_recvreq  =  recvreq ;
110- #endif   /* !OPAL_ENABLE_MULTI_THREADS */ 
111113        }
112-     OBJ_CONSTRUCT (recvreq , mca_pml_ob1_recv_request_t );
113114
114115    MCA_PML_OB1_RECV_REQUEST_INIT (recvreq , addr , count , datatype ,
115116                                  src , tag , comm , false);
@@ -126,8 +127,17 @@ int mca_pml_ob1_recv(void *addr,
126127    }
127128
128129    rc  =  recvreq -> req_recv .req_base .req_ompi .req_status .MPI_ERROR ;
129-     MCA_PML_BASE_RECV_REQUEST_FINI (& recvreq -> req_recv );
130-     OBJ_DESTRUCT (recvreq );
130+ 
131+ #if  OMPI_ENABLE_THREAD_MULTIPLE 
132+     MCA_PML_OB1_RECV_REQUEST_RETURN (recvreq );
133+ #else 
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+     }
140+ #endif 
131141
132142    return  rc ;
133143}
0 commit comments