aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2018-04-27 14:55:05 +0200
committerHans Nilsson <[email protected]>2018-05-14 12:56:47 +0200
commitc4f0b4f2b868b47ceb7cc29b78acc162a353720a (patch)
treed3480d24bd1278de6568fbd4a65f6f75e1b0ba4d /lib/ssh
parent1c22f3cb6a170183fd3c8e938162a01bc82a2677 (diff)
downloadotp-c4f0b4f2b868b47ceb7cc29b78acc162a353720a.tar.gz
otp-c4f0b4f2b868b47ceb7cc29b78acc162a353720a.tar.bz2
otp-c4f0b4f2b868b47ceb7cc29b78acc162a353720a.zip
ssh: Unfold function in the single used place
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/src/ssh_connection_handler.erl27
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 311c5a2cd6..2ad6f779d3 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -1421,9 +1421,17 @@ handle_event(info, {timeout, {_, From} = Request}, _,
end;
%%% Handle that ssh channels user process goes down
-handle_event(info, {'DOWN', _Ref, process, ChannelPid, _Reason}, _, D0) ->
- {keep_state, handle_channel_down(ChannelPid, D0)};
-
+handle_event(info, {'DOWN', _Ref, process, ChannelPid, _Reason}, _, D) ->
+ Cache = cache(D),
+ ssh_client_channel:cache_foldl(
+ fun(#channel{user=U,
+ local_id=Id}, Acc) when U == ChannelPid ->
+ ssh_client_channel:cache_delete(Cache, Id),
+ Acc;
+ (_,Acc) ->
+ Acc
+ end, [], Cache),
+ {keep_state, cache_check_set_idle_timer(D)};
handle_event(info, idle_timer_timeout, StateName, _) ->
{stop, {shutdown, "Timeout"}};
@@ -1895,19 +1903,6 @@ handle_request(ChannelId, Type, Data, WantReply, From, D) ->
end.
%%%----------------------------------------------------------------
-handle_channel_down(ChannelPid, D) ->
- Cache = cache(D),
- ssh_client_channel:cache_foldl(
- fun(#channel{user=U,
- local_id=Id}, Acc) when U == ChannelPid ->
- ssh_client_channel:cache_delete(Cache, Id),
- Acc;
- (_,Acc) ->
- Acc
- end, [], Cache),
- cache_check_set_idle_timer(D).
-
-
update_sys(Cache, Channel, Type, ChannelPid) ->
ssh_client_channel:cache_update(Cache,
Channel#channel{sys = Type, user = ChannelPid}).