aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_peer_fsm.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2014-05-22 02:09:23 +0200
committerAnders Svensson <[email protected]>2014-05-23 12:04:05 +0200
commit58a070c491e7f2f87a3c6bb09a5c05208a9aa333 (patch)
tree5950784baf1724298ff3a6eb0cdcbc33f00af5b7 /lib/diameter/src/base/diameter_peer_fsm.erl
parent6642bfc89b9a9863ea1f4864d28b96b075beedd8 (diff)
downloadotp-58a070c491e7f2f87a3c6bb09a5c05208a9aa333.tar.gz
otp-58a070c491e7f2f87a3c6bb09a5c05208a9aa333.tar.bz2
otp-58a070c491e7f2f87a3c6bb09a5c05208a9aa333.zip
Count encode errors in outgoing messages
Only decode errors were counted previously. Keys are of the form {Id, send, error}, where Id is: {ApplicationId, CommandCode, Rbit} | unknown The latter will be the case if not even a #diameter_header{} can be constructed.
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, 25 insertions, 19 deletions
diff --git a/lib/diameter/src/base/diameter_peer_fsm.erl b/lib/diameter/src/base/diameter_peer_fsm.erl
index 4978c1e049..74086e75b0 100644
--- a/lib/diameter/src/base/diameter_peer_fsm.erl
+++ b/lib/diameter/src/base/diameter_peer_fsm.erl
@@ -296,7 +296,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.
@@ -619,7 +620,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};
@@ -627,10 +628,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
@@ -650,7 +656,7 @@ handle_request(Type, #diameter_packet{} = Pkt, #state{dictionary = D} = S) ->
%% send_answer/3
send_answer(Type, ReqPkt, #state{transport = TPid, dictionary = Dict} = S) ->
- diameter_traffic:incr_R(recv, ReqPkt, TPid),
+ incr_error(recv, ReqPkt),
#diameter_packet{header = H,
transport_data = TD}
@@ -660,18 +666,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) ->
@@ -884,7 +890,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),