File tree 1 file changed +3
-3
lines changed
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};
14
14
15
15
pub struct RWLock {
16
16
inner : UnsafeCell < libc:: pthread_rwlock_t > ,
17
- write_locked : UnsafeCell < bool > ,
17
+ write_locked : UnsafeCell < bool > , // guarded by the `inner` RwLock
18
18
num_readers : AtomicUsize ,
19
19
}
20
20
@@ -52,13 +52,13 @@ impl RWLock {
52
52
// allow that because it could lead to aliasing issues.
53
53
if r == libc:: EAGAIN {
54
54
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 ( ) ) {
56
56
if r == 0 {
57
57
self . raw_unlock ( ) ;
58
58
}
59
59
panic ! ( "rwlock read lock would result in deadlock" ) ;
60
60
} else {
61
- debug_assert_eq ! ( r, 0 ) ;
61
+ assert_eq ! ( r, 0 ) ;
62
62
self . num_readers . fetch_add ( 1 , Ordering :: Relaxed ) ;
63
63
}
64
64
}
You can’t perform that action at this time.
0 commit comments