aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh_sftp.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2016-06-01 11:47:52 +0200
committerHans Nilsson <[email protected]>2016-06-01 11:47:52 +0200
commit317079a89bdf69888e398cb7e5703bfda7bd2c74 (patch)
tree82e0a323967b1506eb21cc0ec652476e4c3933ac /lib/ssh/src/ssh_sftp.erl
parentb2cefac14a6b26c78f584592801413611ff6f31c (diff)
parent84051a76ee4c07f7453ba2bf24fe32c8cf8c7b48 (diff)
downloadotp-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.erl23
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, [], [], []),