aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh.erl
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2012-11-16 15:07:02 +0100
committerFredrik Gustafsson <[email protected]>2012-11-16 15:07:02 +0100
commit67bb449ebc3e51a39c73b04eefb25feba6e1aa1e (patch)
treeaa7752f9851ad87409542d206adb279598207841 /lib/ssh/src/ssh.erl
parent9278347678eea78419c0c310f767eaa1f4be4040 (diff)
parent49fef147845655e44f91cd4fdf4be92162e65710 (diff)
downloadotp-67bb449ebc3e51a39c73b04eefb25feba6e1aa1e.tar.gz
otp-67bb449ebc3e51a39c73b04eefb25feba6e1aa1e.tar.bz2
otp-67bb449ebc3e51a39c73b04eefb25feba6e1aa1e.zip
Merge branch 'fredrik/ssh/timer-on-connect/OTP-10514'
* fredrik/ssh/timer-on-connect/OTP-10514: New setup in testing idle_time Use same connect as the rest of testcases Fixed doc Added testcase for idle timer Not start the idle timer on connect Doc about idle_time option to ssh:connect Check cache on channel exec handle no idle-timer on check cache Option idle_time introduced, it will trigger the timer and if it is not given the timer_ref entry is infinity Timeout after 1h of idle on connection, which exits the connection Conflicts: lib/ssh/src/ssh.erl
Diffstat (limited to 'lib/ssh/src/ssh.erl')
-rw-r--r--lib/ssh/src/ssh.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index 7d68b1d7bd..a569298056 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -79,7 +79,7 @@ connect(Host, Port, Options, Timeout) ->
DisableIpv6 = proplists:get_value(ip_v6_disabled, SshOptions, false),
Inet = inetopt(DisableIpv6),
do_connect(Host, Port, [Inet | SocketOptions],
- [{user_pid, self()}, {host, Host} | SshOptions], Timeout, DisableIpv6)
+ [{user_pid, self()}, {host, Host} | fix_idle_time(SshOptions)], Timeout, DisableIpv6)
end.
do_connect(Host, Port, SocketOptions, SshOptions, Timeout, DisableIpv6) ->
@@ -246,6 +246,13 @@ shell(Host, Port, Options) ->
%%--------------------------------------------------------------------
%%% Internal functions
%%--------------------------------------------------------------------
+fix_idle_time(SshOptions) ->
+ case proplists:get_value(idle_time, SshOptions) of
+ undefined ->
+ [{idle_time, infinity}|SshOptions];
+ _ ->
+ SshOptions
+ end.
start_daemon(Host, Port, Options, Inet) ->
case handle_options(Options) of
{error, _Reason} = Error ->
@@ -355,6 +362,8 @@ handle_option([{pref_public_key_algs, _} = Opt | Rest], SocketOptions, SshOption
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([{quiet_mode, _} = Opt|Rest], SocketOptions, SshOptions) ->
handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
+handle_option([{idle_time, _} = Opt | Rest], SocketOptions, SshOptions) ->
+ handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]);
handle_option([Opt | Rest], SocketOptions, SshOptions) ->
handle_option(Rest, [handle_inet_option(Opt) | SocketOptions], SshOptions).
@@ -430,6 +439,8 @@ handle_ssh_option({shell, Value} = Opt) when is_function(Value) ->
handle_ssh_option({quiet_mode, Value} = Opt) when Value == true;
Value == false ->
Opt;
+handle_ssh_option({idle_time, Value} = Opt) when is_integer(Value), Value > 0 ->
+ Opt;
handle_ssh_option(Opt) ->
throw({error, {eoptions, Opt}}).