diff options
author | Anders Svensson <[email protected]> | 2011-12-20 14:51:42 +0100 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2011-12-20 14:51:42 +0100 |
commit | 0610ab240d5b4bdfe8b5a23f34dcbae81ba9adce (patch) | |
tree | cee96b89ff7e487cebad5ca5397f3569f8489a4b /lib/diameter/src/base/diameter_watchdog.erl | |
parent | 40d571461d8fa708028fc6cb91ef6a1905cddd3c (diff) | |
parent | 8a7b17a6d63377c323ab137ca8c0847280f9e24a (diff) | |
download | otp-0610ab240d5b4bdfe8b5a23f34dcbae81ba9adce.tar.gz otp-0610ab240d5b4bdfe8b5a23f34dcbae81ba9adce.tar.bz2 otp-0610ab240d5b4bdfe8b5a23f34dcbae81ba9adce.zip |
Merge branch 'anders/diameter/missed_events/OTP-9824' into maint
* anders/diameter/missed_events/OTP-9824:
Update watchdog suite
Ensure capabilities exchange can't fail too early
Diffstat (limited to 'lib/diameter/src/base/diameter_watchdog.erl')
-rw-r--r-- | lib/diameter/src/base/diameter_watchdog.erl | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/lib/diameter/src/base/diameter_watchdog.erl b/lib/diameter/src/base/diameter_watchdog.erl index 6dc53d9f31..fb22fd8275 100644 --- a/lib/diameter/src/base/diameter_watchdog.erl +++ b/lib/diameter/src/base/diameter_watchdog.erl @@ -59,10 +59,19 @@ message_data}). %% term passed into diameter_service with message %% start/2 +%% +%% Start a monitor before the watchdog is allowed to proceed to ensure +%% that a failed capabilities exchange produces the desired exit +%% reason. start({_,_} = Type, T) -> - {ok, Pid} = diameter_watchdog_sup:start_child({Type, self(), T}), - Pid. + Ref = make_ref(), + {ok, Pid} = diameter_watchdog_sup:start_child({Ref, {Type, self(), T}}), + try + {erlang:monitor(process, Pid), Pid} + after + Pid ! Ref + end. start_link(T) -> {ok, _} = proc_lib:start_link(?MODULE, @@ -80,14 +89,29 @@ init(T) -> proc_lib:init_ack({ok, self()}), gen_server:enter_loop(?MODULE, [], i(T)). -i({T, Pid, {ConnT, Opts, SvcName, #diameter_service{applications = Apps, - capabilities = Caps} - = Svc}}) -> - {M,S,U} = now(), - random:seed(M,S,U), +i({Ref, {_, Pid, _} = T}) -> + MRef = erlang:monitor(process, Pid), + receive + Ref -> + make_state(T); + {'DOWN', MRef, process, _, _} = D -> + exit({shutdown, D}) + end; + +i({_, Pid, _} = T) -> %% from old code + erlang:monitor(process, Pid), + make_state(T). + +make_state({T, Pid, {ConnT, + Opts, + SvcName, + #diameter_service{applications = Apps, + capabilities = Caps} + = Svc}}) -> + random:seed(now()), putr(restart, {T, Opts, Svc}), %% save seeing it in trace putr(dwr, dwr(Caps)), %% - #watchdog{parent = monitor(Pid), + #watchdog{parent = Pid, transport = monitor(diameter_peer_fsm:start(T, Opts, Svc)), tw = proplists:get_value(watchdog_timer, Opts, |