aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-06-19 02:45:05 +0200
committerAnders Svensson <[email protected]>2015-06-19 03:03:14 +0200
commit25f280a5af09bba20ca9db84ebfd9d0d67f3c7ff (patch)
treee195bec2cbbaf658f997b388f703cdf1e0f89522 /lib/diameter/src
parentc6c18a2eca711e738b187b4f7aa0bd2a4765bea3 (diff)
downloadotp-25f280a5af09bba20ca9db84ebfd9d0d67f3c7ff.tar.gz
otp-25f280a5af09bba20ca9db84ebfd9d0d67f3c7ff.tar.bz2
otp-25f280a5af09bba20ca9db84ebfd9d0d67f3c7ff.zip
Simplify accepting transport start
Don't pass an association id that's no longer used.
Diffstat (limited to 'lib/diameter/src')
-rw-r--r--lib/diameter/src/transport/diameter_sctp.erl34
1 files changed, 15 insertions, 19 deletions
diff --git a/lib/diameter/src/transport/diameter_sctp.erl b/lib/diameter/src/transport/diameter_sctp.erl
index f2949c1242..41f5ea7ce8 100644
--- a/lib/diameter/src/transport/diameter_sctp.erl
+++ b/lib/diameter/src/transport/diameter_sctp.erl
@@ -224,7 +224,7 @@ i({listen, Ref, {Opts, Addrs}}) ->
proc_lib:init_ack({ok, self(), LAs}),
start_timer(#listener{ref = Ref,
socket = Sock,
- accept = accept(Matches)});
+ accept = [[M] || {accept, M} <- Matches]});
%% A connecting transport.
i({connect, Pid, Opts, Addrs, Ref}) ->
@@ -241,7 +241,7 @@ i({connect, Pid, Opts, Addrs, Ref}) ->
%% An accepting transport spawned by diameter, not yet owning an
%% association.
-i({accept, Pid, LPid, Ref})
+i({accept, Ref, LPid, Pid})
when is_pid(Pid) ->
putr(?REF_KEY, Ref),
proc_lib:init_ack({ok, self()}),
@@ -250,8 +250,9 @@ i({accept, Pid, LPid, Ref})
wait([{peeloff, MRef}], #transport{parent = Pid,
mode = {accept, LPid}});
-%% An accepting transport spawned at association establishment.
-i({accept, Ref, LPid, _Id}) ->
+%% An accepting transport spawned at association establishment, whose
+%% parent is not yet known.
+i({accept, Ref, LPid}) ->
putr(?REF_KEY, Ref),
proc_lib:init_ack({ok, self()}),
erlang:send_after(?ACCEPT_TIMEOUT, self(), accept_timeout),
@@ -482,7 +483,7 @@ l({sctp, Sock, _RA, _RP, Data} = T, #listener{socket = Sock,
accept = Matches}
= S) ->
Id = assoc_id(Data),
- {TPid, NewS} = accept(Id, S),
+ {TPid, NewS} = accept(S),
TPid ! {peeloff, setelement(2, T, peeloff(Sock, Id, TPid)), Matches},
setopts(Sock),
NewS;
@@ -586,11 +587,6 @@ accept_peer(Sock, Matches) ->
orelse x({accept, RAddrs, Matches}),
ok.
-%% accept/1
-
-accept(Opts) ->
- [[M] || {accept, M} <- Opts].
-
%% accept/3
%%
%% Start a new transport process or use one that's already been
@@ -607,7 +603,7 @@ accept(_, Pid, #listener{ref = Ref,
%% No pending associations: spawn a new transport.
accept(Ref, Pid, #listener{pending = {_,Q}}) ->
- nq({accept, Pid, self(), Ref}, Q).
+ nq({accept, Ref, self(), Pid}, Q).
%% send/2
@@ -718,25 +714,25 @@ up(#transport{parent = Pid,
diameter_peer:up(Pid),
S#transport{mode = A}.
-%% accept/2
+%% accept/1
%%
%% Start a new transport process or use one that's already been
%% started as a consequence of an event to a listener process.
-accept(Id, #listener{pending = {N,Q}} = S) ->
- {tpid(Id, S), S#listener{pending = {N+1,Q}}}.
+accept(#listener{pending = {N,Q}} = S) ->
+ {tpid(S), S#listener{pending = {N+1,Q}}}.
-%% tpid/2
+%% tpid/1
%% Transport waiting for an association: use it.
-tpid(_Id, #listener{pending = {N,Q}})
+tpid(#listener{pending = {N,Q}})
when N < 0 ->
dq(Q);
%% No transport start yet: spawn one and queue.
-tpid(Id, #listener{ref = Ref,
- pending = {_,Q}}) ->
- nq({accept, Ref, self(), Id}, Q).
+tpid(#listener{ref = Ref,
+ pending = {_,Q}}) ->
+ nq({accept, Ref, self()}, Q).
%% nq/2
%%