diff options
author | Sverker Eriksson <[email protected]> | 2017-08-18 19:56:02 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2017-11-15 20:10:33 +0100 |
commit | 17e198d6ee60f7dec9abfed272cf4226aea44535 (patch) | |
tree | 15d5eaa19c9e0533133b59c2c09261aedcdb7acc /erts/emulator/beam | |
parent | 3f5f22656a33aec1ba4ed01249732e32d08a8c50 (diff) | |
download | otp-17e198d6ee60f7dec9abfed272cf4226aea44535.tar.gz otp-17e198d6ee60f7dec9abfed272cf4226aea44535.tar.bz2 otp-17e198d6ee60f7dec9abfed272cf4226aea44535.zip |
erts: Async auto-connect for monitor/2
Diffstat (limited to 'erts/emulator/beam')
-rw-r--r-- | erts/emulator/beam/bif.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c index 2583a5f8d6..2af61e6ebc 100644 --- a/erts/emulator/beam/bif.c +++ b/erts/emulator/beam/bif.c @@ -790,31 +790,20 @@ remote_monitor(Process *p, Eterm bifarg1, Eterm bifarg2, BIF_RETTYPE ret; int code; + ASSERT(dep); erts_proc_lock(p, ERTS_PROC_LOCK_LINK); code = erts_dsig_prepare(&dsd, &dep, p, (ERTS_PROC_LOCK_MAIN | ERTS_PROC_LOCK_LINK), - ERTS_DSP_RLOCK, 0, 0); + ERTS_DSP_RLOCK, 0, 1); switch (code) { - case ERTS_DSIG_PREP_PENDING: - /* - * Must wait for connection to know if node supports monitor. - * Damn these synchronous errors. - */ - erts_smp_de_runlock(dep); - /* fall through */ case ERTS_DSIG_PREP_NOT_ALIVE: case ERTS_DSIG_PREP_NOT_CONNECTED: erts_proc_unlock(p, ERTS_PROC_LOCK_LINK); ERTS_BIF_PREP_TRAP2(ret, dmonitor_p_trap, p, bifarg1, bifarg2); break; + case ERTS_DSIG_PREP_PENDING: case ERTS_DSIG_PREP_CONNECTED: - if (!(dep->flags & DFLAG_DIST_MONITOR) - || (byname && !(dep->flags & DFLAG_DIST_MONITOR_NAME))) { - erts_de_runlock(dep); - erts_proc_unlock(p, ERTS_PROC_LOCK_LINK); - ERTS_BIF_PREP_ERROR(ret, p, BADARG); - } - else { + { Eterm p_trgt, p_name, d_name, mon_ref; mon_ref = erts_make_ref(p); @@ -917,17 +906,17 @@ local_port: if (!erts_is_alive && remote_node != am_Noname) { goto badarg; /* Remote monitor from (this) undistributed node */ } - dep = erts_sysname_to_connected_dist_entry(remote_node); + dep = erts_find_or_insert_dist_entry(remote_node); if (dep == erts_this_dist_entry) { ret = local_name_monitor(BIF_P, BIF_ARG_1, name); } else { ret = remote_monitor(BIF_P, BIF_ARG_1, BIF_ARG_2, dep, name, 1); } + erts_deref_dist_entry(dep); } else { badarg: ERTS_BIF_PREP_ERROR(ret, BIF_P, BADARG); } - return ret; } |