Skip to content

Commit dc6caac

Browse files
committed
Make sys::windows::process use RawMutex
1 parent cba8507 commit dc6caac

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/libstd/sys/windows/process.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use mem;
2222
use os::windows::ffi::OsStrExt;
2323
use path::Path;
2424
use ptr;
25-
use sys::mutex::Mutex;
2625
use sys::c;
2726
use sys::fs::{OpenOptions, File};
2827
use sys::handle::Handle;
@@ -31,6 +30,7 @@ use sys::stdio;
3130
use sys::cvt;
3231
use sys_common::{AsInner, FromInner, IntoInner};
3332
use sys_common::process::{CommandEnv, EnvKey};
33+
use sys_common::parking_lot::raw_mutex::RawMutex;
3434
use borrow::Borrow;
3535

3636
////////////////////////////////////////////////////////////////////////////////
@@ -98,7 +98,7 @@ pub struct StdioPipes {
9898
}
9999

100100
struct DropGuard<'a> {
101-
lock: &'a Mutex,
101+
lock: &'a RawMutex,
102102
}
103103

104104
impl Command {
@@ -186,7 +186,7 @@ impl Command {
186186
//
187187
// For more information, msdn also has an article about this race:
188188
// http://support.microsoft.com/kb/315939
189-
static CREATE_PROCESS_LOCK: Mutex = Mutex::new();
189+
static CREATE_PROCESS_LOCK: RawMutex = RawMutex::INIT;
190190
let _guard = DropGuard::new(&CREATE_PROCESS_LOCK);
191191

192192
let mut pipes = StdioPipes {
@@ -238,19 +238,15 @@ impl fmt::Debug for Command {
238238
}
239239

240240
impl<'a> DropGuard<'a> {
241-
fn new(lock: &'a Mutex) -> DropGuard<'a> {
242-
unsafe {
243-
lock.lock();
244-
DropGuard { lock }
245-
}
241+
fn new(lock: &'a RawMutex) -> DropGuard<'a> {
242+
lock.lock();
243+
DropGuard { lock }
246244
}
247245
}
248246

249247
impl<'a> Drop for DropGuard<'a> {
250248
fn drop(&mut self) {
251-
unsafe {
252-
self.lock.unlock();
253-
}
249+
self.lock.unlock();
254250
}
255251
}
256252

0 commit comments

Comments
 (0)