File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -25,12 +25,24 @@ static ompi_wait_sync_t* wait_sync_list = NULL;
2525
2626int  sync_wait_mt (ompi_wait_sync_t  * sync )
2727{
28+     /* Don't stop if the waiting synchronization is completed. We avoid the 
29+      * race condition around the release of the synchronization using the 
30+      * signaling field. 
31+      */ 
2832    if (sync -> count  <= 0 )
2933        return  (0  ==  sync -> status ) ? OPAL_SUCCESS  : OPAL_ERROR ;
3034
3135    /* lock so nobody can signal us during the list updating */ 
3236    pthread_mutex_lock (& sync -> lock );
3337
38+     /* Now that we hold the lock make sure another thread has not already 
39+      * call cond_signal. 
40+      */ 
41+     if (sync -> count  <= 0 ) {
42+         pthread_mutex_unlock (& sync -> lock );
43+         return  (0  ==  sync -> status ) ? OPAL_SUCCESS  : OPAL_ERROR ;
44+     }
45+ 
3446    /* Insert sync on the list of pending synchronization constructs */ 
3547    OPAL_THREAD_LOCK (& wait_sync_lock );
3648    if ( NULL  ==  wait_sync_list  ) {
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments