about summary refs log tree commit diff
path: root/src/libnative
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnative')
-rw-r--r--src/libnative/io/net.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs
index ac68b1523d7..cf0b1f05ebd 100644
--- a/src/libnative/io/net.rs
+++ b/src/libnative/io/net.rs
@@ -201,14 +201,20 @@ pub fn init() {
     }
 
     unsafe {
-        use std::unstable::mutex::{Once, ONCE_INIT};
-        static mut INIT: Once = ONCE_INIT;
-        INIT.doit(|| {
-            let mut data: WSADATA = intrinsics::init();
-            let ret = WSAStartup(0x202,      // version 2.2
-                                 &mut data);
-            assert_eq!(ret, 0);
-        });
+        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();
+        }
     }
 }