aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2013-04-09 01:38:34 +0200
committerAnders Svensson <[email protected]>2013-04-10 12:50:39 +0200
commitc609108ce017069a77708f80dae9e89c45ff222d (patch)
treec9fb31ef4b7ce04b94833cfe02fcab14ed00b7fe /lib
parent157886e6b69e9c7cf1e0e6f8ea932a82b810ea12 (diff)
downloadotp-c609108ce017069a77708f80dae9e89c45ff222d.tar.gz
otp-c609108ce017069a77708f80dae9e89c45ff222d.tar.bz2
otp-c609108ce017069a77708f80dae9e89c45ff222d.zip
Fix watchdog table leak
A service process maintains a table keyed on watchdog process pids. When a watchdog process dies the corresponding entry should be removed but this was broken in commit f115a9f7, causing entries with watchdog state DOWN to accumulate. Watchdog processes die as a result of diameter:remove_transport/2, or when a peer reestablishes a connection in the listening case. Neither is typically a frequent occurrence. The fault manifests itself in the return value of diameter:service_info(SvcName, transport), which displays entries for watchdog processes that are no longer alive.
Diffstat (limited to 'lib')
-rw-r--r--lib/diameter/src/base/diameter_service.erl24
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl
index e4d1c60727..112e83476d 100644
--- a/lib/diameter/src/base/diameter_service.erl
+++ b/lib/diameter/src/base/diameter_service.erl
@@ -861,17 +861,21 @@ watchdog(TPid, [], ?WD_SUSPECT, ?WD_OKAY, Wd, State) ->
%% Watchdog has an unresponsive connection.
watchdog(TPid, [], ?WD_OKAY, ?WD_SUSPECT = To, Wd, State) ->
#watchdog{peer = TPid} = Wd, %% assert
- connection_down(Wd, To, State);
+ watchdog_down(Wd, To, State);
%% Watchdog has lost its connection.
watchdog(TPid, [], _, ?WD_DOWN = To, Wd, #state{peerT = PeerT} = S) ->
close(Wd, S),
- connection_down(Wd, To, S),
+ watchdog_down(Wd, To, S),
ets:delete(PeerT, TPid);
watchdog(_, [], _, _, _, _) ->
ok.
+watchdog_down(Wd, To, #state{watchdogT = WatchdogT} = S) ->
+ insert(WatchdogT, Wd#watchdog{state = To}),
+ connection_down(Wd, To, S).
+
%% ---------------------------------------------------------------------------
%% # connection_up/3
%% ---------------------------------------------------------------------------
@@ -1029,21 +1033,17 @@ connection_down(#watchdog{state = ?WD_OKAY,
remove_local_peer(SApps, {{TPid, Caps}, {SvcName, Apps}}, LDict),
diameter_traffic:peer_down(TPid);
-connection_down(#watchdog{}, #peer{}, _) ->
- ok;
-
-connection_down(#watchdog{state = WS,
+connection_down(#watchdog{state = ?WD_OKAY,
peer = TPid}
= Wd,
To,
- #state{watchdogT = WatchdogT,
- peerT = PeerT}
+ #state{peerT = PeerT}
= S)
when is_atom(To) ->
- insert(WatchdogT, Wd#watchdog{state = To}),
- ?WD_OKAY == WS
- andalso
- connection_down(Wd, fetch(PeerT, TPid), S).
+ connection_down(Wd, #peer{} = fetch(PeerT, TPid), S);
+
+connection_down(#watchdog{}, _, _) ->
+ ok.
remove_local_peer(SApps, T, LDict) ->
lists:foldl(fun(A,D) -> rlp(A, T, D) end, LDict, SApps).