We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d722944 commit b4fe8f3Copy full SHA for b4fe8f3
library/std/src/sys/unix/locks/pthread_rwlock.rs
@@ -17,6 +17,21 @@ impl LazyInit for RwLock {
17
fn init() -> Box<Self> {
18
Box::new(Self::new())
19
}
20
+
21
+ fn destroy(mut rwlock: Box<Self>) {
22
+ // We're not allowed to pthread_rwlock_destroy a locked rwlock,
23
+ // so check first if it's unlocked.
24
+ if *rwlock.write_locked.get_mut() || *rwlock.num_readers.get_mut() != 0 {
25
+ // The rwlock is locked. This happens if a RwLock{Read,Write}Guard is leaked.
26
+ // In this case, we just leak the RwLock too.
27
+ forget(rwlock);
28
+ }
29
30
31
+ fn cancel_init(_: Box<Self>) {
32
+ // In this case, we can just drop it without any checks,
33
+ // since it cannot have been locked yet.
34
35
36
37
impl RwLock {
0 commit comments