diff options
author | Anders Svensson <[email protected]> | 2013-01-24 16:16:05 +0100 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2013-02-08 15:28:56 +0100 |
commit | 34b008c323591b0c02f42287c86b9a788aab51ad (patch) | |
tree | 566c448d20c5cf0216d1c445b5189019a2ab4c9a /lib/diameter/src/base/diameter_service.erl | |
parent | 74755d8d18aa1769840b0914fe73e9c5c4b3219b (diff) | |
download | otp-34b008c323591b0c02f42287c86b9a788aab51ad.tar.gz otp-34b008c323591b0c02f42287c86b9a788aab51ad.tar.bz2 otp-34b008c323591b0c02f42287c86b9a788aab51ad.zip |
Simplify transport shutdown
Service process informs the watchdog process which informs the peer
process. (Instead of going directly to the latter in one case.)
Diffstat (limited to 'lib/diameter/src/base/diameter_service.erl')
-rw-r--r-- | lib/diameter/src/base/diameter_service.erl | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl index 4e6cb3cd79..d01a5e5ab6 100644 --- a/lib/diameter/src/base/diameter_service.erl +++ b/lib/diameter/src/base/diameter_service.erl @@ -716,46 +716,30 @@ mod_state(Alias, ModS) -> %%% # shutdown/2 %%% --------------------------------------------------------------------------- -%% remove_transport: ask watchdogs to terminate their transport. +%% remove_transport shutdown(Refs, #state{peerT = PeerT}) when is_list(Refs) -> - ets:foldl(fun(P,ok) -> sp(P, Refs), ok end, ok, PeerT); + ets:foldl(fun(P,ok) -> st(P, Refs), ok end, ok, PeerT); -%% application/service shutdown: ask transports to terminate themselves. -shutdown(Reason, #state{peerT = PeerT}) -> - %% A transport might not be alive to receive the shutdown request - %% but give those that are a chance to shutdown gracefully. - shutdown(conn, Reason, PeerT), - %% Kill the watchdogs explicitly in case there was no transport. - shutdown(peer, Reason, PeerT). +%% application/service shutdown +shutdown(Reason, #state{peerT = PeerT}) + when Reason == application; + Reason == service -> + diameter_lib:wait(ets:foldl(fun(P,A) -> st(P, Reason, A) end, + [], + PeerT)). -%% sp/2 +%% st/2 -sp(#peer{ref = Ref, pid = Pid}, Refs) -> +st(#peer{ref = Ref, pid = Pid}, Refs) -> lists:member(Ref, Refs) - andalso (Pid ! {shutdown, self()}). %% 'DOWN' cleans up - -%% shutdown/3 - -shutdown(Who, Reason, T) -> - diameter_lib:wait(ets:foldl(fun(X,A) -> shutdown(Who, X, Reason, A) end, - [], - T)). + andalso (Pid ! {shutdown, self(), transport}). %% 'DOWN' cleans up -shutdown(conn, - #peer{pid = Pid, op_state = {?STATE_UP, _}, conn = TPid}, - Reason, - Acc) -> - TPid ! {shutdown, Pid, Reason}, - [TPid | Acc]; +%% st/3 -shutdown(peer, #peer{pid = Pid}, _Reason, Acc) - when is_pid(Pid) -> - exit(Pid, shutdown), - [Pid | Acc]; - -shutdown(_, #peer{}, _, Acc) -> - Acc. +st(#peer{pid = Pid}, Reason, Acc) -> + Pid ! {shutdown, self(), Reason}, + [Pid | Acc]. %%% --------------------------------------------------------------------------- %%% # call_service/2 |