Skip to content

Commit 445b79b

Browse files
committed
ompi/request: fix hang in ompi_request_wait_completion
This commit fixes a hang reported by @nysal which happens when a request is completed after a sync object is created but before the sync object can be assigned to the request. In this case we need to set the sync signaling field to false to ensure WAIT_SYNC_RELEASE does not hang. Fixes #1828 Signed-off-by: Nathan Hjelm <[email protected]>
1 parent 679a66c commit 445b79b

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)