Fix undefined behavior when re-locking a mutex from the same thread
The only applies to pthread mutexes. We solve this by creating the mutex with the PTHREAD_MUTEX_NORMAL type, which guarantees that re-locking from the same thread will deadlock.
This commit is contained in:
@@ -64,6 +64,8 @@ impl Mutex {
|
||||
held: UnsafeCell::new(false),
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub unsafe fn init(&mut self) {}
|
||||
pub unsafe fn lock(&self) {
|
||||
match kind() {
|
||||
Kind::SRWLock => c::AcquireSRWLockExclusive(raw(self)),
|
||||
|
||||
Reference in New Issue
Block a user