aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2012-02-22 19:25:59 +0100
committerSverker Eriksson <[email protected]>2012-02-23 12:19:42 +0100
commit6d7073e33a8f326b8a37eaf5539aa322a06a732c (patch)
tree7f4f87f1649772b17899fbdc63bbea37ebccdd62 /erts/emulator/beam/erl_nif.c
parent17c62a8d1158e2c13be403e62d81140c705a8444 (diff)
downloadotp-6d7073e33a8f326b8a37eaf5539aa322a06a732c.tar.gz
otp-6d7073e33a8f326b8a37eaf5539aa322a06a732c.tar.bz2
otp-6d7073e33a8f326b8a37eaf5539aa322a06a732c.zip
erts: Seize code_ix lock when updating trace settings
We want to avoid the race when trace settings are done in the time gap while a code stager process is waiting for thread process before commiting and releasing code_ix lock.
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 8e8b58a7ad..a0182630b9 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -1513,6 +1513,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
if (len < 0) {
BIF_ERROR(BIF_P, BADARG);
}
+
lib_name = (char *) erts_alloc(ERTS_ALC_T_TMP, len + 1);
if (intlist_to_buf(BIF_ARG_1, lib_name, len) != len) {
@@ -1521,6 +1522,12 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
}
lib_name[len] = '\0';
+ if (!erts_try_lock_code_ix(BIF_P)) {
+ erts_free(ERTS_ALC_T_TMP, lib_name);
+ ERTS_BIF_YIELD2(bif_export[BIF_load_nif_2],
+ BIF_P, BIF_ARG_1, BIF_ARG_2);
+ }
+
/* Block system (is this the right place to do it?) */
erts_smp_proc_unlock(BIF_P, ERTS_PROC_LOCK_MAIN);
erts_smp_thr_progress_block();
@@ -1715,6 +1722,7 @@ BIF_RETTYPE load_nif_2(BIF_ALIST_2)
erts_smp_thr_progress_unblock();
erts_smp_proc_lock(BIF_P, ERTS_PROC_LOCK_MAIN);
+ erts_unlock_code_ix();
erts_free(ERTS_ALC_T_TMP, lib_name);
if (reload_warning) {