Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions opal/threads/wait_sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,24 @@ static ompi_wait_sync_t* wait_sync_list = NULL;

int sync_wait_mt(ompi_wait_sync_t *sync)
{
/* Don't stop if the waiting synchronization is completed. We avoid the
* race condition around the release of the synchronization using the
* signaling field.
*/
if(sync->count <= 0)
return (0 == sync->status) ? OPAL_SUCCESS : OPAL_ERROR;

/* lock so nobody can signal us during the list updating */
pthread_mutex_lock(&sync->lock);

/* Now that we hold the lock make sure another thread has not already
* call cond_signal.
*/
if(sync->count <= 0) {
pthread_mutex_unlock(&sync->lock);
return (0 == sync->status) ? OPAL_SUCCESS : OPAL_ERROR;
}

/* Insert sync on the list of pending synchronization constructs */
OPAL_THREAD_LOCK(&wait_sync_lock);
if( NULL == wait_sync_list ) {
Expand Down