aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-03-15 22:33:17 +0100
committerAnders Svensson <[email protected]>2017-06-11 16:30:33 +0200
commit2d74fa618f3a34a5487f5de37c4f6e2870b58273 (patch)
treeb74aef1242593a94ff029e97c1264a1abffdd9e6
parent6b7ec6db6bd999a509e867aef438b3b8769cae43 (diff)
downloadotp-2d74fa618f3a34a5487f5de37c4f6e2870b58273.tar.gz
otp-2d74fa618f3a34a5487f5de37c4f6e2870b58273.tar.bz2
otp-2d74fa618f3a34a5487f5de37c4f6e2870b58273.zip
Fix handling of message length errors
Message length errors in incoming messages were misinterpreted with transport_opt() {length_errors, exit} due to the throw introduced in commit 2ffb288: the corresponding catch in incoming/2 caught errors thrown by close/1, leading to failure when the error reason was interpreted as a diameter_packet record. Do away with the throw, that also caused woe in the parent commit.
-rw-r--r--lib/diameter/src/base/diameter_peer_fsm.erl42
1 files changed, 19 insertions, 23 deletions
diff --git a/lib/diameter/src/base/diameter_peer_fsm.erl b/lib/diameter/src/base/diameter_peer_fsm.erl
index 7ee1e5fe59..d394156367 100644
--- a/lib/diameter/src/base/diameter_peer_fsm.erl
+++ b/lib/diameter/src/base/diameter_peer_fsm.erl
@@ -444,7 +444,8 @@ transition({connection_timeout, _}, _) ->
%% Incoming message from the transport.
transition({diameter, {recv, MsgT}}, S) ->
- incoming(MsgT, S);
+ {Msg, NPid} = msg(MsgT),
+ incoming(recv(Msg, S), NPid, S);
%% Timeout when still in the same state ...
transition({timeout = T, PS}, #state{state = PS}) ->
@@ -609,31 +610,26 @@ encode(Rec, Dict) ->
diameter_codec:encode(Dict, #diameter_packet{header = Hdr,
msg = Rec}).
-%% incoming/2
+%% incoming/3
-incoming({Msg, NPid}, S) ->
- try recv(Msg, S) of
- T ->
- NPid ! {diameter, discard},
- T
- catch
- {?MODULE, Name, Pkt} ->
- incoming(Name, Pkt, NPid, S)
- end;
+incoming({recv, Name, Pkt}, NPid, #state{parent = Pid} = S) ->
+ Pid ! {recv, self(), get_route(Pkt), Name, Pkt, NPid},
+ rcv(Name, Pkt, S);
-incoming(Msg, S) ->
- try
- recv(Msg, S)
- catch
- {?MODULE, Name, Pkt} ->
- incoming(Name, Pkt, false, S)
- end.
+incoming(T, false, _) ->
+ T;
-%% incoming/4
+incoming(T, NPid, _) ->
+ NPid ! {diameter, discard},
+ T.
-incoming(Name, Pkt, NPid, #state{parent = Pid} = S) ->
- Pid ! {recv, self(), get_route(Pkt), Name, Pkt, NPid},
- rcv(Name, Pkt, S).
+%% msg/1
+
+msg({_,_} = T) ->
+ T;
+
+msg(Msg) ->
+ {Msg, false}.
%% recv/2
@@ -701,7 +697,7 @@ recv1('DPA' = N,
%% Any other message with a header and no length errors: send to the
%% parent.
recv1(Name, Pkt, #state{}) ->
- throw({?MODULE, Name, Pkt}).
+ {recv, Name, Pkt}.
%% recv/3