File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use sync::atomic::{AtomicUsize, Ordering};
1414
1515pub struct RWLock {
1616 inner : UnsafeCell < libc:: pthread_rwlock_t > ,
17- write_locked : UnsafeCell < bool > ,
17+ write_locked : UnsafeCell < bool > , // guarded by the `inner` RwLock
1818 num_readers : AtomicUsize ,
1919}
2020
@@ -52,13 +52,13 @@ impl RWLock {
5252 // allow that because it could lead to aliasing issues.
5353 if r == libc:: EAGAIN {
5454 panic ! ( "rwlock maximum reader count exceeded" ) ;
55- } else if r == libc:: EDEADLK || * self . write_locked . get ( ) {
55+ } else if r == libc:: EDEADLK || ( r == 0 && * self . write_locked . get ( ) ) {
5656 if r == 0 {
5757 self . raw_unlock ( ) ;
5858 }
5959 panic ! ( "rwlock read lock would result in deadlock" ) ;
6060 } else {
61- debug_assert_eq ! ( r, 0 ) ;
61+ assert_eq ! ( r, 0 ) ;
6262 self . num_readers . fetch_add ( 1 , Ordering :: Relaxed ) ;
6363 }
6464 }
You can’t perform that action at this time.
0 commit comments