aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_peer_fsm.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2014-05-25 09:30:59 +0200
committerAnders Svensson <[email protected]>2014-05-25 09:30:59 +0200
commit6202139d7680be7df2fc5a6d6138409c1ae780d6 (patch)
treed4720faae1220868e6211290ec8061fbbeb63778 /lib/diameter/src/base/diameter_peer_fsm.erl
parent5782c3aad85c5c1e644d160504d9c8d27ffdc2f1 (diff)
parent58a070c491e7f2f87a3c6bb09a5c05208a9aa333 (diff)
downloadotp-6202139d7680be7df2fc5a6d6138409c1ae780d6.tar.gz
otp-6202139d7680be7df2fc5a6d6138409c1ae780d6.tar.bz2
otp-6202139d7680be7df2fc5a6d6138409c1ae780d6.zip
Merge branch 'anders/diameter/rc_counters/OTP-11937' into maint
* anders/diameter/rc_counters/OTP-11937: Count encode errors in outgoing messages Count decode errors in incoming requests Count decode errors independently of result codes
Diffstat (limited to 'lib/diameter/src/base/diameter_peer_fsm.erl')
-rw-r--r--lib/diameter/src/base/diameter_peer_fsm.erl44
1 files changed, 26 insertions, 18 deletions
diff --git a/lib/diameter/src/base/diameter_peer_fsm.erl b/lib/diameter/src/base/diameter_peer_fsm.erl
index ac87c1a2c1..4b97fa96b3 100644
--- a/lib/diameter/src/base/diameter_peer_fsm.erl
+++ b/lib/diameter/src/base/diameter_peer_fsm.erl
@@ -292,7 +292,8 @@ handle_info(T, #state{} = State) ->
?LOG(stop, T),
{stop, {shutdown, T}, State}
catch
- exit: {diameter_codec, encode, _} = Reason ->
+ exit: {diameter_codec, encode, T} = Reason ->
+ incr_error(send, T),
?LOG(stop, Reason),
%% diameter_codec:encode/2 emits an error report. Only
%% indicate the probable reason here.
@@ -615,7 +616,7 @@ rcv('DPA' = N,
transport = TPid,
dpr = {Hid, Eid}}) ->
- incr_A(recv, diameter_codec:decode(Dict0, Pkt), Dict0),
+ incr_rc(recv, diameter_codec:decode(Dict0, Pkt), Dict0),
diameter_peer:close(TPid),
{stop, N};
@@ -623,10 +624,15 @@ rcv('DPA' = N,
rcv(_, _, _) ->
ok.
-%% incr_A/3
+%% incr_rc/3
-incr_A(Dir, Pkt, Dict0) ->
- diameter_traffic:incr_A(Dir, Pkt, self(), Dict0).
+incr_rc(Dir, Pkt, Dict0) ->
+ diameter_traffic:incr_rc(Dir, Pkt, self(), Dict0).
+
+%% incr_error/2
+
+incr_error(Dir, Pkt) ->
+ diameter_traffic:incr_error(Dir, Pkt, self()).
%% send/2
@@ -646,6 +652,8 @@ handle_request(Type, #diameter_packet{} = Pkt, #state{dictionary = D} = S) ->
%% send_answer/3
send_answer(Type, ReqPkt, #state{transport = TPid, dictionary = Dict} = S) ->
+ incr_error(recv, ReqPkt),
+
#diameter_packet{header = H,
transport_data = TD}
= ReqPkt,
@@ -654,18 +662,18 @@ send_answer(Type, ReqPkt, #state{transport = TPid, dictionary = Dict} = S) ->
%% An answer message clears the R and T flags and retains the P
%% flag. The E flag is set at encode.
- Pkt0 = #diameter_packet{header
- = H#diameter_header{version = ?DIAMETER_VERSION,
- is_request = false,
- is_error = undefined,
- is_retransmitted = false},
- msg = Msg,
- transport_data = TD},
-
- Pkt = diameter_codec:encode(Dict, Pkt0),
-
- incr_A(send, Pkt, Dict),
- send(TPid, Pkt),
+ Pkt = #diameter_packet{header
+ = H#diameter_header{version = ?DIAMETER_VERSION,
+ is_request = false,
+ is_error = undefined,
+ is_retransmitted = false},
+ msg = Msg,
+ transport_data = TD},
+
+ AnsPkt = diameter_codec:encode(Dict, Pkt),
+
+ incr_rc(send, AnsPkt, Dict),
+ send(TPid, AnsPkt),
eval(PostF, S).
eval([F|A], S) ->
@@ -874,7 +882,7 @@ handle_CEA(#diameter_packet{bin = Bin}
= DPkt
= diameter_codec:decode(Dict0, Pkt),
- RC = result_code(incr_A(recv, DPkt, Dict0)),
+ RC = result_code(incr_rc(recv, DPkt, Dict0)),
{SApps, IS, RCaps} = recv_CEA(DPkt, S),