File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -1077,7 +1077,7 @@ rlock_acquire_restore(PyObject *op, PyObject *args)
10771077        return  NULL ;
10781078
10791079    _PyRecursiveMutex_Lock (& self -> lock );
1080-     self -> lock .thread   =   owner ;
1080+     _Py_atomic_store_ullong_relaxed ( & self -> lock .thread ,  owner ) ;
10811081    self -> lock .level  =  count  -  1 ;
10821082    Py_RETURN_NONE ;
10831083}
@@ -1093,17 +1093,16 @@ rlock_release_save(PyObject *op, PyObject *Py_UNUSED(ignored))
10931093{
10941094    rlockobject  * self  =  (rlockobject * )op ;
10951095
1096-     PyThread_ident_t  owner  =  self -> lock .thread ;
1097-     size_t  count  =  self -> lock .level  +  1 ;
1098- 
1099-     if  (_PyRecursiveMutex_TryUnlock (& self -> lock ) <  0 )
1100-     {
1096+     if  (!_PyRecursiveMutex_IsLockedByCurrentThread (& self -> lock )) {
11011097        PyErr_SetString (PyExc_RuntimeError ,
11021098                        "cannot release un-acquired lock" );
11031099        return  NULL ;
11041100    }
1105-     self -> lock .thread  =  0 ;
1106-     self -> lock .level  =  0 ;
1101+ 
1102+     PyThread_ident_t  owner  =  self -> lock .thread ;
1103+     size_t  count  =  self -> lock .level  +  1 ;
1104+     self -> lock .level  =  0 ;  // ensure the unlock releases the lock 
1105+     _PyRecursiveMutex_Unlock (& self -> lock );
11071106    return  Py_BuildValue ("k"  Py_PARSE_THREAD_IDENT_T , count , owner );
11081107}
11091108
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments