aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-07-25 20:23:53 +0200
committerSverker Eriksson <[email protected]>2017-07-25 20:23:53 +0200
commit0b4e79dc173d562d05d93867d5cc9f1711ad0582 (patch)
treed13fb0540250fe5cec181fd8756065f94f701287 /erts/emulator/beam/erl_nif.c
parent13193403c7ec44632db37b455640867c1cf87f60 (diff)
parent5e8f74d6c2d98f22e5f32e866064974de6ee4e33 (diff)
downloadotp-0b4e79dc173d562d05d93867d5cc9f1711ad0582.tar.gz
otp-0b4e79dc173d562d05d93867d5cc9f1711ad0582.tar.bz2
otp-0b4e79dc173d562d05d93867d5cc9f1711ad0582.zip
Merge branch 'sverker/enif_whereis-bug/OTP-14523' into maint
* sverker/enif_whereis-bug: erts: Fix bug in enif_whereis_pid/port
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r--erts/emulator/beam/erl_nif.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c
index 848e116621..d3c5af3a83 100644
--- a/erts/emulator/beam/erl_nif.c
+++ b/erts/emulator/beam/erl_nif.c
@@ -889,26 +889,27 @@ static Eterm call_whereis(ErlNifEnv *env, Eterm name)
Process *c_p;
Eterm res;
int scheduler;
- int unlock;
execution_state(env, &c_p, &scheduler);
ASSERT((c_p && scheduler) || (!c_p && !scheduler));
- unlock = 0;
if (scheduler < 0) {
/* dirty scheduler */
if (ERTS_PROC_IS_EXITING(c_p))
return 0;
- if (env->proc->static_flags & ERTS_STC_FLG_SHADOW_PROC) {
- erts_smp_proc_lock(c_p, ERTS_PROC_LOCK_MAIN);
- unlock = 1;
- }
+ if (env->proc->static_flags & ERTS_STC_FLG_SHADOW_PROC)
+ c_p = NULL; /* as we don't have main lock */
}
- res = erts_whereis_name_to_id(c_p, name);
- if (unlock)
- erts_smp_proc_unlock(c_p, ERTS_PROC_LOCK_MAIN);
+
+ if (c_p) {
+ /* main lock may be released below and c_p->htop updated by others */
+ flush_env(env);
+ }
+ res = erts_whereis_name_to_id(c_p, name);
+ if (c_p)
+ cache_env(env);
return res;
}