about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-01-27 22:41:25 -0800
committerAlex Crichton <alex@alexcrichton.com>2014-02-03 12:05:16 -0800
commitacacfb20fd34162cfba5a4e7b5f1447e0403fa50 (patch)
tree0790d82726f49abc6d37b8ac5c8ca0fbec7e0685 /src/libnative
parent984727ff87bb8a9f345ababf473d1141f9e05c08 (diff)
downloadrust-acacfb20fd34162cfba5a4e7b5f1447e0403fa50.tar.gz
rust-acacfb20fd34162cfba5a4e7b5f1447e0403fa50.zip
Various bug fixes and rebase conflicts
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/net.rs19
-rw-r--r--src/libnative/io/timer_helper.rs12
2 files changed, 17 insertions, 14 deletions
diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs
index cf0b1f05ebd..dd916c8f3c4 100644
--- a/src/libnative/io/net.rs
+++ b/src/libnative/io/net.rs
@@ -204,17 +204,16 @@ pub fn init() {
         use std::unstable::mutex::{Mutex, MUTEX_INIT};
         static mut INITIALIZED: bool = false;
         static mut LOCK: Mutex = MUTEX_INIT;
-        unsafe {
-            LOCK.lock();
-            if !INITIALIZED {
-                let mut data: WSADATA = intrinsics::init();
-                let ret = WSAStartup(0x202,      // version 2.2
-                                     &mut data);
-                assert_eq!(ret, 0);
-                INITIALIZED = true;
-            }
-            LOCK.unlock();
+
+        LOCK.lock();
+        if !INITIALIZED {
+            let mut data: WSADATA = intrinsics::init();
+            let ret = WSAStartup(0x202,      // version 2.2
+                                 &mut data);
+            assert_eq!(ret, 0);
+            INITIALIZED = true;
         }
+        LOCK.unlock();
     }
 }
 
diff --git a/src/libnative/io/timer_helper.rs b/src/libnative/io/timer_helper.rs
index 7311be46e8b..c00b0efadb5 100644
--- a/src/libnative/io/timer_helper.rs
+++ b/src/libnative/io/timer_helper.rs
@@ -22,7 +22,7 @@
 
 use std::cast;
 use std::rt;
-use std::unstable::mutex::{Once, ONCE_INIT};
+use std::unstable::mutex::{Mutex, MUTEX_INIT};
 
 use bookkeeping;
 use io::timer::{Req, Shutdown};
@@ -37,10 +37,12 @@ static mut HELPER_CHAN: *mut SharedChan<Req> = 0 as *mut SharedChan<Req>;
 static mut HELPER_SIGNAL: imp::signal = 0 as imp::signal;
 
 pub fn boot(helper: fn(imp::signal, Port<Req>)) {
-    static mut INIT: Once = ONCE_INIT;
+    static mut LOCK: Mutex = MUTEX_INIT;
+    static mut INITIALIZED: bool = false;
 
     unsafe {
-        INIT.doit(|| {
+        LOCK.lock();
+        if !INITIALIZED {
             let (msgp, msgc) = SharedChan::new();
             HELPER_CHAN = cast::transmute(~msgc);
             let (receive, send) = imp::new();
@@ -52,7 +54,9 @@ pub fn boot(helper: fn(imp::signal, Port<Req>)) {
             });
 
             rt::at_exit(proc() { shutdown() });
-        })
+            INITIALIZED = true;
+        }
+        LOCK.unlock();
     }
 }