Skip to content

Commit 892e1ed

Browse files
committed
Fix a potential race condition in which a progress matching thread could match a request while we are cancelling it.
1 parent c9f7bb6 commit 892e1ed

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ompi/mca/pml/ob1/pml_ob1_recvreq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,14 @@ static int mca_pml_ob1_recv_request_cancel(struct ompi_request_t* ompi_request,
103103
ompi_communicator_t *comm = request->req_recv.req_base.req_comm;
104104
mca_pml_ob1_comm_t *ob1_comm = comm->c_pml_comm;
105105

106+
/* The rest should be protected behind the match logic lock */
107+
OPAL_THREAD_LOCK(&ob1_comm->matching_lock);
106108
if( true == request->req_match_received ) { /* way to late to cancel this one */
109+
OPAL_THREAD_UNLOCK(&ob1_comm->matching_lock);
107110
assert( OMPI_ANY_TAG != ompi_request->req_status.MPI_TAG ); /* not matched isn't it */
108111
return OMPI_SUCCESS;
109112
}
110113

111-
/* The rest should be protected behind the match logic lock */
112-
OPAL_THREAD_LOCK(&ob1_comm->matching_lock);
113114
if( request->req_recv.req_base.req_peer == OMPI_ANY_SOURCE ) {
114115
opal_list_remove_item( &ob1_comm->wild_receives, (opal_list_item_t*)request );
115116
} else {

0 commit comments

Comments
 (0)