diff options
author | Erlang/OTP <[email protected]> | 2014-08-20 14:53:43 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2014-08-20 14:53:43 +0200 |
commit | b440d8cb0e98a4f8941e0440035e0b11a69dddd9 (patch) | |
tree | 040527af4e52e5d5628d6bcbd0bdb816397f1f2c /lib/ssh/src/ssh_connection_handler.erl | |
parent | c472c3f5aafc81a409d0443c4601de43bafb53cb (diff) | |
parent | 788e59b860213dfdbe3ee1768150f49fcc1bfeff (diff) | |
download | otp-b440d8cb0e98a4f8941e0440035e0b11a69dddd9.tar.gz otp-b440d8cb0e98a4f8941e0440035e0b11a69dddd9.tar.bz2 otp-b440d8cb0e98a4f8941e0440035e0b11a69dddd9.zip |
Merge branch 'hans/ssh/patch-17.0.2' into maint-17
* hans/ssh/patch-17.0.2:
ssh: Updated vsn.mk
ssh: negotiation_timeout bug fixed
ssh: Negotiation_timeout testcase
Diffstat (limited to 'lib/ssh/src/ssh_connection_handler.erl')
-rw-r--r-- | lib/ssh/src/ssh_connection_handler.erl | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index 06866392da..86804c4436 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -104,21 +104,11 @@ start_connection(client = Role, Socket, Options, Timeout) -> start_connection(server = Role, Socket, Options, Timeout) -> try - Sups = proplists:get_value(supervisors, Options), - ConnectionSup = proplists:get_value(connection_sup, Sups), - Opts = [{supervisors, Sups}, {user_pid, self()} | proplists:get_value(ssh_opts, Options, [])], - {ok, Pid} = ssh_connection_sup:start_child(ConnectionSup, [Role, Socket, Opts]), - {_, Callback, _} = proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}), - socket_control(Socket, Pid, Callback), - case proplists:get_value(parallel_login, Opts, false) of + case proplists:get_value(parallel_login, Options, false) of true -> - spawn(fun() -> - Ref = erlang:monitor(process, Pid), - handshake(Pid, Ref, Timeout) - end); + spawn(fun() -> start_server_connection(Role, Socket, Options, Timeout) end); false -> - Ref = erlang:monitor(process, Pid), - handshake(Pid, Ref, Timeout) + start_server_connection(Role, Socket, Options, Timeout) end catch exit:{noproc, _} -> @@ -127,6 +117,18 @@ start_connection(server = Role, Socket, Options, Timeout) -> {error, Error} end. + +start_server_connection(server = Role, Socket, Options, Timeout) -> + Sups = proplists:get_value(supervisors, Options), + ConnectionSup = proplists:get_value(connection_sup, Sups), + Opts = [{supervisors, Sups}, {user_pid, self()} | proplists:get_value(ssh_opts, Options, [])], + {ok, Pid} = ssh_connection_sup:start_child(ConnectionSup, [Role, Socket, Opts]), + {_, Callback, _} = proplists:get_value(transport, Options, {tcp, gen_tcp, tcp_closed}), + socket_control(Socket, Pid, Callback), + Ref = erlang:monitor(process, Pid), + handshake(Pid, Ref, Timeout). + + start_link(Role, Socket, Options) -> {ok, proc_lib:spawn_link(?MODULE, init, [[Role, Socket, Options]])}. |