aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_watchdog.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-06-27 09:47:55 +0200
committerAnders Svensson <[email protected]>2013-07-12 16:40:00 +0200
commite762d7d10b045623272430a91326eb936733acf0 (patch)
tree534902fb24b6a0c71453de54f51d8ba66304840e /lib/diameter/src/base/diameter_watchdog.erl
parentb055e89956269543b08bc7c3a17c3fadf41f0f13 (diff)
downloadotp-e762d7d10b045623272430a91326eb936733acf0.tar.gz
otp-e762d7d10b045623272430a91326eb936733acf0.tar.bz2
otp-e762d7d10b045623272430a91326eb936733acf0.zip
Ensure DWR isn't sent immediately after DWA
Having the peer_fsm process answer DWR meant that watchdog timer expiry could result in an outgoing DWR despite the fact that an incoming DWR was just answered. Having the watchdog process answer avoids this. diameter_peer_fsm must be loaded before diameter_watchdog. It's possible for one incoming DWR to go unanswered but a subsequent DWR will be answered so no harm is done.
Diffstat (limited to 'lib/diameter/src/base/diameter_watchdog.erl')
-rw-r--r--lib/diameter/src/base/diameter_watchdog.erl19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/diameter/src/base/diameter_watchdog.erl b/lib/diameter/src/base/diameter_watchdog.erl
index 88ccf630e2..7e75801718 100644
--- a/lib/diameter/src/base/diameter_watchdog.erl
+++ b/lib/diameter/src/base/diameter_watchdog.erl
@@ -201,7 +201,7 @@ common_dictionary(Apps) ->
%% means a user won't be able either send of receive
%% messages in the common dictionary: incoming request
%% will be answered with 3007 and outgoing requests cannot
- %% be sent. The dictionary returned here is oly used for
+ %% be sent. The dictionary returned here is only used for
%% messages diameter sends and receives: CER/CEA, DPR/DPA
%% and DWR/DWA.
?BASE
@@ -545,10 +545,15 @@ recv(Name, Pkt, S) ->
%% rcv/3
+rcv('DWR', Pkt, #watchdog{transport = TPid,
+ dictionary = Dict0,
+ sequence = Mask}) ->
+ send(TPid, {send, encode(dwa(Pkt), Mask, Dict0)}),
+ ?LOG(send, 'DWA');
+
rcv(N, _, _)
when N == 'CER';
N == 'CEA';
- N == 'DWR';
N == 'DWA';
N == 'DPR';
N == 'DPA' ->
@@ -642,6 +647,9 @@ rcv('DWA', #watchdog{status = reopen,
%% REOPEN Receive non-DWA Throwaway() REOPEN
+rcv('DWR', #watchdog{status = reopen} = S) ->
+ S; %% ensure DWA: the RFC isn't explicit about answering
+
rcv(_, #watchdog{status = reopen} = S) ->
throwaway(S).
@@ -782,6 +790,13 @@ dwr(#diameter_caps{origin_host = OH,
{'Origin-Realm', OR},
{'Origin-State-Id', OSI}].
+%% dwa/1
+
+dwa(#diameter_packet{header = H, errors = Es}) ->
+ {RC, FailedAVP} = diameter_peer_fsm:result_code(H, Es),
+ ['DWA', {'Result-Code', RC}
+ | tl(getr(dwr)) ++ FailedAVP].
+
%% restrict_nodes/1
restrict_nodes(false) ->