aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2011-03-02 14:29:02 +0100
committerPatrik Nyblom <[email protected]>2011-03-02 14:29:12 +0100
commitcf79166291cda7267c48bb708efe273c603d2a91 (patch)
tree07c90bec6e3b4c65b02937fa5402cd8fedeecfca
parent455ff4bc78f94c997d43a46fd2619b7d683c10c5 (diff)
parentc971c489dc8318ca4e92e9ba40d739dc4ee50982 (diff)
downloadotp-cf79166291cda7267c48bb708efe273c603d2a91.tar.gz
otp-cf79166291cda7267c48bb708efe273c603d2a91.tar.bz2
otp-cf79166291cda7267c48bb708efe273c603d2a91.zip
Merge branch 'pan/wx_macos_main_thread' into dev
* pan/wx_macos_main_thread: Remove race in main thread stealing due to reading and writing to pipe from same thread OTP-9081
-rw-r--r--erts/emulator/beam/erl_drv_thread.c3
-rw-r--r--erts/emulator/sys/unix/sys.c10
2 files changed, 8 insertions, 5 deletions
diff --git a/erts/emulator/beam/erl_drv_thread.c b/erts/emulator/beam/erl_drv_thread.c
index 08a35387f2..39bbe9633b 100644
--- a/erts/emulator/beam/erl_drv_thread.c
+++ b/erts/emulator/beam/erl_drv_thread.c
@@ -698,6 +698,7 @@ erl_drv_thread_join(ErlDrvTid tid, void **respp)
#if defined(__DARWIN__) && defined(USE_THREADS) && defined(ERTS_SMP)
extern int erts_darwin_main_thread_pipe[2];
+extern int erts_darwin_main_thread_result_pipe[2];
int
@@ -709,7 +710,7 @@ erl_drv_stolen_main_thread_join(ErlDrvTid tid, void **respp)
x = &dummy;
else
x = respp;
- read(erts_darwin_main_thread_pipe[0],x,sizeof(void *));
+ read(erts_darwin_main_thread_result_pipe[0],x,sizeof(void *));
return 0;
}
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index 5f38d73359..bafbbb0f6c 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -2997,10 +2997,12 @@ init_smp_sig_notify(void)
#ifdef __DARWIN__
int erts_darwin_main_thread_pipe[2];
+int erts_darwin_main_thread_result_pipe[2];
-static void initialize_darwin_main_thread_pipe(void)
+static void initialize_darwin_main_thread_pipes(void)
{
- if (pipe(erts_darwin_main_thread_pipe) < 0) {
+ if (pipe(erts_darwin_main_thread_pipe) < 0 ||
+ pipe(erts_darwin_main_thread_result_pipe) < 0) {
erl_exit(1,"Fatal error initializing Darwin main thread stealing");
}
}
@@ -3011,7 +3013,7 @@ erts_sys_main_thread(void)
{
erts_thread_disable_fpe();
#ifdef __DARWIN__
- initialize_darwin_main_thread_pipe();
+ initialize_darwin_main_thread_pipes();
#endif
/* Become signal receiver thread... */
#ifdef ERTS_ENABLE_LOCK_CHECK
@@ -3039,7 +3041,7 @@ erts_sys_main_thread(void)
read(erts_darwin_main_thread_pipe[0],&func,sizeof(void* (*)(void*)));
read(erts_darwin_main_thread_pipe[0],&arg, sizeof(void*));
resp = (*func)(arg);
- write(erts_darwin_main_thread_pipe[1],&resp,sizeof(void *));
+ write(erts_darwin_main_thread_result_pipe[1],&resp,sizeof(void *));
}
#else
#ifdef DEBUG