Skip to content

Commit f691e92

Browse files
committed
---
yaml --- r: 61354 b: refs/heads/try c: f6401ba h: refs/heads/master v: v3
1 parent 2b20fd5 commit f691e92

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: 36ad366519137122871b04b407370dab4a97c645
5+
refs/heads/try: f6401bad24d2fb1e1f959595c2f57cb4964e7082
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/os.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,23 +147,25 @@ pub mod win32 {
147147

148148
/*
149149
Accessing environment variables is not generally threadsafe.
150-
This uses a per-runtime lock to serialize access.
151-
FIXME #4726: It would probably be appropriate to make this a real global
150+
Serialize access through a global lock.
152151
*/
153152
fn with_env_lock<T>(f: &fn() -> T) -> T {
154-
use unstable::global::global_data_clone_create;
155-
use unstable::sync::{Exclusive, exclusive};
156-
157-
struct SharedValue(());
158-
type ValueMutex = Exclusive<SharedValue>;
159-
fn key(_: ValueMutex) { }
153+
use unstable::finally::Finally;
160154

161155
unsafe {
162-
let lock: ValueMutex = global_data_clone_create(key, || {
163-
~exclusive(SharedValue(()))
164-
});
156+
return do (|| {
157+
rust_take_env_lock();
158+
f()
159+
}).finally {
160+
rust_drop_env_lock();
161+
};
162+
}
165163

166-
lock.with_imm(|_| f() )
164+
extern {
165+
#[fast_ffi]
166+
fn rust_take_env_lock();
167+
#[fast_ffi]
168+
fn rust_drop_env_lock();
167169
}
168170
}
169171

branches/try/src/libuv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit 97ac7c087a0caf6b0f611b80e14f7fe3cb18bb27
1+
Subproject commit 218ab86721eefd7b7e97fa6d9f95a80a1fa8686c

branches/try/src/rt/rust_env.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// that might come from the environment is loaded here, once, during
1414
// init.
1515

16+
#include "sync/lock_and_signal.h"
1617
#include "rust_env.h"
1718

1819
// The environment variables that the runtime knows about
@@ -26,6 +27,18 @@
2627
#define RUST_DEBUG_MEM "RUST_DEBUG_MEM"
2728
#define RUST_DEBUG_BORROW "RUST_DEBUG_BORROW"
2829

30+
static lock_and_signal env_lock;
31+
32+
extern "C" CDECL void
33+
rust_take_env_lock() {
34+
env_lock.lock();
35+
}
36+
37+
extern "C" CDECL void
38+
rust_drop_env_lock() {
39+
env_lock.unlock();
40+
}
41+
2942
#if defined(__WIN32__)
3043
static int
3144
get_num_cpus() {
@@ -119,6 +132,8 @@ copyenv(const char* name) {
119132

120133
rust_env*
121134
load_env(int argc, char **argv) {
135+
scoped_lock with(env_lock);
136+
122137
rust_env *env = (rust_env*)malloc(sizeof(rust_env));
123138

124139
env->num_sched_threads = (size_t)get_num_threads();
@@ -141,3 +156,4 @@ free_env(rust_env *env) {
141156
free(env->rust_seed);
142157
free(env);
143158
}
159+

branches/try/src/rt/rustrt.def.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,7 @@ rust_begin_unwind
235235
rust_take_task_borrow_list
236236
rust_set_task_borrow_list
237237
rust_valgrind_stack_register
238-
rust_valgrind_stack_deregister
238+
rust_valgrind_stack_deregister
239+
rust_take_env_lock
240+
rust_drop_env_lock
241+

0 commit comments

Comments
 (0)