aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-06-19 01:26:06 +0200
committerAnders Svensson <[email protected]>2015-06-19 03:03:14 +0200
commit1d3827223b0c4174ab39fa6af3e969e4a62f598f (patch)
tree2aa6bc31f972ef84a7da09f4ff8843524174cd36
parent083ae6d719a8ab5d626ad4b28e836475b6c1a92b (diff)
downloadotp-1d3827223b0c4174ab39fa6af3e969e4a62f598f.tar.gz
otp-1d3827223b0c4174ab39fa6af3e969e4a62f598f.tar.bz2
otp-1d3827223b0c4174ab39fa6af3e969e4a62f598f.zip
Don't monitor listener after peeloff
Listener death should have no effect on a peeled off association.
-rw-r--r--lib/diameter/src/transport/diameter_sctp.erl32
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/diameter/src/transport/diameter_sctp.erl b/lib/diameter/src/transport/diameter_sctp.erl
index 29ac73a6a6..51b4858ab0 100644
--- a/lib/diameter/src/transport/diameter_sctp.erl
+++ b/lib/diameter/src/transport/diameter_sctp.erl
@@ -246,19 +246,19 @@ i({accept, Pid, LPid, LSock, Ref})
putr(?REF_KEY, Ref),
proc_lib:init_ack({ok, self()}),
monitor(process, Pid),
- monitor(process, LPid),
- wait([peeloff], #transport{parent = Pid,
- mode = {accept, LPid},
- socket = LSock});
+ MRef = monitor(process, LPid),
+ wait([{peeloff, MRef}], #transport{parent = Pid,
+ mode = {accept, LPid},
+ socket = LSock});
%% An accepting transport spawned at association establishment.
i({accept, Ref, LPid, LSock, _Id}) ->
putr(?REF_KEY, Ref),
proc_lib:init_ack({ok, self()}),
erlang:send_after(?ACCEPT_TIMEOUT, self(), accept_timeout),
- monitor(process, LPid),
- wait([Ref, peeloff], #transport{mode = {accept, LPid},
- socket = LSock}).
+ MRef = monitor(process, LPid),
+ wait([{parent, Ref}, {peeloff, MRef}], #transport{mode = {accept, LPid},
+ socket = LSock}).
%% wait/2
%%
@@ -268,15 +268,16 @@ i({accept, Ref, LPid, LSock, _Id}) ->
wait(Keys, S) ->
lists:foldl(fun i/2, S, Keys).
-i(K, #transport{mode = {accept, _},
- socket = LSock}
- = S) ->
+i({K, Ref}, #transport{mode = {accept, _},
+ socket = LSock}
+ = S) ->
receive
- {K, Pid} when is_reference(K) -> %% transport process started
+ {Ref, Pid} when K == parent -> %% transport process started
S#transport{parent = Pid};
{K, Sock, T, Matches} when K == peeloff -> %% association
{sctp, LSock, _RA, _RP, _Data} = T, %% assert
ok = accept_peer(Sock, Matches),
+ demonitor(Ref, [flush]),
t(setelement(2, T, Sock), S#transport{socket = Sock});
accept_timeout = T ->
x(T);
@@ -575,15 +576,6 @@ transition({diameter, {tls, _Ref, _Type, _Bool}}, _) ->
transition({'DOWN', _, process, Pid, _}, #transport{parent = Pid}) ->
stop;
-%% Listener process has died.
-transition({'DOWN', _, process, Pid, _}, #transport{mode = {accept, Pid}}) ->
- stop;
-
-%% Ditto but we have ownership of the association. It might be that
-%% we'll go down anyway though.
-transition({'DOWN', _, process, _Pid, _}, #transport{mode = accept}) ->
- ok;
-
%% Timeout after transport process has been started.
transition(accept_timeout, _) ->
ok;