Skip to content

Commit f38cc00

Browse files
authored
Merge pull request #1835 from hjelmn/thread_fix
ompi/request: fix hang in ompi_request_wait_completion
2 parents 2cf0e5d + 445b79b commit f38cc00

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ompi/request/request.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,15 @@ static inline int ompi_request_free(ompi_request_t** request)
377377

378378
static inline void ompi_request_wait_completion(ompi_request_t *req)
379379
{
380-
if (opal_using_threads ()) {
380+
if (opal_using_threads () && !REQUEST_COMPLETE(req)) {
381381
ompi_wait_sync_t sync;
382382
WAIT_SYNC_INIT(&sync, 1);
383383

384-
if(OPAL_ATOMIC_CMPSET_PTR(&req->req_complete, REQUEST_PENDING, &sync)) {
384+
if (OPAL_ATOMIC_CMPSET_PTR(&req->req_complete, REQUEST_PENDING, &sync)) {
385385
SYNC_WAIT(&sync);
386+
} else {
387+
/* completed before we had a chance to swap in the sync object */
388+
WAIT_SYNC_SIGNALLED(&sync);
386389
}
387390

388391
assert(REQUEST_COMPLETE(req));

0 commit comments

Comments
 (0)