From e762d7d10b045623272430a91326eb936733acf0 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Thu, 27 Jun 2013 09:47:55 +0200 Subject: 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. --- lib/diameter/src/base/diameter_watchdog.erl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lib/diameter/src/base/diameter_watchdog.erl') 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) -> -- cgit v1.2.3