aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/dist.h
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-09-26 16:01:29 +0200
committerSverker Eriksson <[email protected]>2017-11-15 20:13:03 +0100
commit25f9d0469e2b1da0aec73b55e54561be8b573634 (patch)
treef22d0603ba50ded3ae4670946fb3a8dfc3250d9c /erts/emulator/beam/dist.h
parent23ba06691aa64d7f05781bc9b2ea448c3710a812 (diff)
downloadotp-25f9d0469e2b1da0aec73b55e54561be8b573634.tar.gz
otp-25f9d0469e2b1da0aec73b55e54561be8b573634.tar.bz2
otp-25f9d0469e2b1da0aec73b55e54561be8b573634.zip
Refactor auto_connect into an outline function
and abort_pending_connection into own utility function.
Diffstat (limited to 'erts/emulator/beam/dist.h')
-rw-r--r--erts/emulator/beam/dist.h42
1 files changed, 7 insertions, 35 deletions
diff --git a/erts/emulator/beam/dist.h b/erts/emulator/beam/dist.h
index b9b39de3b6..2685a55b97 100644
--- a/erts/emulator/beam/dist.h
+++ b/erts/emulator/beam/dist.h
@@ -148,6 +148,8 @@ ERTS_GLB_INLINE int erts_dsig_prepare(ErtsDSigData *,
ERTS_GLB_INLINE
void erts_schedule_dist_command(Port *, DistEntry *);
+int erts_auto_connect(DistEntry* dep, Process *proc, ErtsProcLocks proc_locks);
+
#if ERTS_GLB_INLINE_INCL_FUNC_DEF
ERTS_GLB_INLINE int
@@ -197,41 +199,11 @@ retry:
else if (connect) {
ASSERT(dep->status == 0);
erts_de_runlock(dep);
- erts_de_rwlock(dep);
- if (dep->status == 0) {
- Process* net_kernel;
- ErtsProcLocks nk_locks = ERTS_PROC_LOCK_MSGQ;
- Eterm *hp;
- ErlOffHeap *ohp;
- ErtsMessage *mp;
- Eterm msg, conn_id, dhandle;
-
- dep->status = ERTS_DE_SFLG_PENDING;
- dep->flags = (DFLAG_DIST_MANDATORY | DFLAG_DIST_HOPEFULLY);
- dep->connection_id++;
- dep->connection_id &= ERTS_DIST_CON_ID_MASK;
- conn_id = make_small(dep->connection_id);
- erts_de_rwunlock(dep);
-
- net_kernel = erts_whereis_process(proc, proc_locks,
- am_net_kernel, nk_locks, 0);
- if (!net_kernel) {
- if (deref_dep)
- erts_deref_dist_entry(dep);
- return ERTS_DSIG_PREP_NOT_ALIVE;
- }
-
- /* Send {auto_connect, Node, ConnId, DHandle} to net_kernel */
- mp = erts_alloc_message_heap(net_kernel, &nk_locks,
- 5 + ERTS_MAGIC_REF_THING_SIZE,
- &hp, &ohp);
- dhandle = erts_build_dhandle(&hp, ohp, dep);
- msg = TUPLE4(hp, am_auto_connect, dep->sysname, conn_id, dhandle);
- erts_queue_message(net_kernel, nk_locks, mp, msg, proc->common.id);
- erts_proc_unlock(net_kernel, nk_locks);
- }
- else
- erts_de_rwunlock(dep);
+ if (!erts_auto_connect(dep, proc, proc_locks)) {
+ if (deref_dep)
+ erts_deref_dist_entry(dep);
+ return ERTS_DSIG_PREP_NOT_ALIVE;
+ }
goto retry;
}
else {