about summary refs log tree commit diff
path: root/src/libstd/sys/windows/mutex.rs
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2016-05-25 05:44:28 +0100
committerAmanieu d'Antras <amanieu@gmail.com>2016-06-02 13:31:01 +0100
commitd73f5e65ecbcb6a0acb908b54226edfccf47eccc (patch)
treeb65444fe5785dbd66b4e04ff14c2575ad475407b /src/libstd/sys/windows/mutex.rs
parenteea4f0c24893d3b5bffec067e6051eb0b5106748 (diff)
downloadrust-d73f5e65ecbcb6a0acb908b54226edfccf47eccc.tar.gz
rust-d73f5e65ecbcb6a0acb908b54226edfccf47eccc.zip
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.
Diffstat (limited to 'src/libstd/sys/windows/mutex.rs')
-rw-r--r--src/libstd/sys/windows/mutex.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/mutex.rs b/src/libstd/sys/windows/mutex.rs
index b770156582d..8762b34e3da 100644
--- a/src/libstd/sys/windows/mutex.rs
+++ b/src/libstd/sys/windows/mutex.rs
@@ -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)),