diff options
author | Hans Nilsson <[email protected]> | 2016-06-01 11:47:52 +0200 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2016-06-01 11:47:52 +0200 |
commit | 317079a89bdf69888e398cb7e5703bfda7bd2c74 (patch) | |
tree | 82e0a323967b1506eb21cc0ec652476e4c3933ac /lib/ssh/src/ssh_sftp.erl | |
parent | b2cefac14a6b26c78f584592801413611ff6f31c (diff) | |
parent | 84051a76ee4c07f7453ba2bf24fe32c8cf8c7b48 (diff) | |
download | otp-317079a89bdf69888e398cb7e5703bfda7bd2c74.tar.gz otp-317079a89bdf69888e398cb7e5703bfda7bd2c74.tar.bz2 otp-317079a89bdf69888e398cb7e5703bfda7bd2c74.zip |
Merge branch 'hans/ssh/use_open_socket_client/OTP-12860'
Diffstat (limited to 'lib/ssh/src/ssh_sftp.erl')
-rw-r--r-- | lib/ssh/src/ssh_sftp.erl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl index b03652a136..afc2fb88ff 100644 --- a/lib/ssh/src/ssh_sftp.erl +++ b/lib/ssh/src/ssh_sftp.erl @@ -95,8 +95,31 @@ %%==================================================================== start_channel(Cm) when is_pid(Cm) -> start_channel(Cm, []); +start_channel(Socket) when is_port(Socket) -> + start_channel(Socket, []); start_channel(Host) when is_list(Host) -> start_channel(Host, []). + +start_channel(Socket, Options) when is_port(Socket) -> + Timeout = + %% A mixture of ssh:connect and ssh_sftp:start_channel: + case proplists:get_value(connect_timeout, Options, undefined) of + undefined -> + proplists:get_value(timeout, Options, infinity); + TO -> + TO + end, + case ssh:connect(Socket, Options, Timeout) of + {ok,Cm} -> + case start_channel(Cm, Options) of + {ok, Pid} -> + {ok, Pid, Cm}; + Error -> + Error + end; + Error -> + Error + end; start_channel(Cm, Opts) when is_pid(Cm) -> Timeout = proplists:get_value(timeout, Opts, infinity), {_, ChanOpts, SftpOpts} = handle_options(Opts, [], [], []), |