diff options
author | Fredrik Gustafsson <[email protected]> | 2012-10-31 10:45:16 +0100 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2012-10-31 10:56:25 +0100 |
commit | 8e8b61c63431096cc8fdd4eaea7d7ed33c143847 (patch) | |
tree | a1343a942e1d1d8819232db8fde705adb3b077e8 /lib/ssh/src/ssh_connection_manager.erl | |
parent | b788929349f4eec4980dd2181d92f7df3687db85 (diff) | |
download | otp-8e8b61c63431096cc8fdd4eaea7d7ed33c143847.tar.gz otp-8e8b61c63431096cc8fdd4eaea7d7ed33c143847.tar.bz2 otp-8e8b61c63431096cc8fdd4eaea7d7ed33c143847.zip |
Check cache on channel exec
Diffstat (limited to 'lib/ssh/src/ssh_connection_manager.erl')
-rw-r--r-- | lib/ssh/src/ssh_connection_manager.erl | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/ssh/src/ssh_connection_manager.erl b/lib/ssh/src/ssh_connection_manager.erl index 6e2fe9da74..9a96542505 100644 --- a/lib/ssh/src/ssh_connection_manager.erl +++ b/lib/ssh/src/ssh_connection_manager.erl @@ -234,6 +234,13 @@ handle_call({request, ChannelPid, ChannelId, Type, Data}, From, State0) -> %% channel is sent later when reply arrives from the connection %% handler. lists:foreach(fun send_msg/1, Replies), + SshOpts = proplists:get_value(ssh_opts, State0#state.opts), + case proplists:get_value(idle_time, SshOpts) of + infinity -> + ok; + _IdleTime -> + erlang:send_after(5000, self(), {check_cache, [], []}) + end, {noreply, State}; handle_call({request, ChannelId, Type, Data}, From, State0) -> @@ -613,18 +620,24 @@ check_cache(State, Cache) -> undefined -> State; Time -> - TimerRef = erlang:send_after(Time, self(), {'EXIT', [], "Timeout"}), - State#state{idle_timer_ref=TimerRef} + case State#state.idle_timer_ref of + undefined -> + TimerRef = erlang:send_after(Time, self(), {'EXIT', [], "Timeout"}), + State#state{idle_timer_ref=TimerRef}; + _ -> + State + end end; _ -> State end. remove_timer_ref(State) -> case State#state.idle_timer_ref of - infinity -> + infinity -> %% If the timer is not activated State; - _ -> - TimerRef = State#state.idle_timer_ref, + undefined -> %% If we already has cancelled the timer + State; + TimerRef -> %% Timer is active erlang:cancel_timer(TimerRef), State#state{idle_timer_ref = undefined} end. |