From a31a7a8376b7df355e468d338b0ecc3f332cd5ee Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Thu, 19 Sep 2024 11:48:23 +0200 Subject: [PATCH 1/3] ssh: remove unused Address from function arguments --- lib/ssh/src/ssh_connection_handler.erl | 8 ++++---- lib/ssh/src/ssh_subsystem_sup.erl | 10 +++++----- lib/ssh/src/ssh_system_sup.erl | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index 4ef45516ca23..93fd84c63d7f 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -42,7 +42,7 @@ %%==================================================================== %%% Start and stop --export([start_link/4, start_link/5, +-export([start_link/3, start_link/4, takeover/4, stop/1 ]). @@ -98,10 +98,10 @@ %% Start / stop %%==================================================================== -start_link(Role, Address, Socket, Options) -> - start_link(Role, Address, undefined, Socket, Options). +start_link(Role, Socket, Options) -> + start_link(Role, undefined, Socket, Options). -start_link(Role, _Address=#address{}, Id, Socket, Options) -> +start_link(Role, Id, Socket, Options) -> case gen_statem:start_link(?MODULE, [Role, Socket, Options], [{spawn_opt, [{message_queue_data,off_heap}]}]) of diff --git a/lib/ssh/src/ssh_subsystem_sup.erl b/lib/ssh/src/ssh_subsystem_sup.erl index ef56c999d2ca..2eb61c6236bd 100644 --- a/lib/ssh/src/ssh_subsystem_sup.erl +++ b/lib/ssh/src/ssh_subsystem_sup.erl @@ -28,7 +28,7 @@ -include("ssh.hrl"). --export([start_link/5, +-export([start_link/4, start_channel/8, tcpip_fwd_supervisor/1 ]). @@ -39,8 +39,8 @@ %%%========================================================================= %%% API %%%========================================================================= -start_link(Role, Address=#address{}, Id, Socket, Options) -> - case supervisor:start_link(?MODULE, [Role, Address, Id, Socket, Options]) of +start_link(Role, Id, Socket, Options) -> + case supervisor:start_link(?MODULE, [Role, Id, Socket, Options]) of {error, {shutdown, {failed_to_start_child, _, Error}}} -> {error,Error}; Other -> @@ -58,7 +58,7 @@ tcpip_fwd_supervisor(SubSysSup) -> %%%========================================================================= %%% Supervisor callback %%%========================================================================= -init([Role, Address, Id, Socket, Options]) -> +init([Role, Id, Socket, Options]) -> SubSysSup = self(), SupFlags = #{strategy => one_for_all, auto_shutdown => any_significant, @@ -71,7 +71,7 @@ init([Role, Address, Id, Socket, Options]) -> significant => true, start => {ssh_connection_handler, start_link, - [Role, Address, Id, Socket, + [Role, Id, Socket, ?PUT_INTERNAL_OPT([ {subsystem_sup, SubSysSup} ], Options) diff --git a/lib/ssh/src/ssh_system_sup.erl b/lib/ssh/src/ssh_system_sup.erl index ed27dc52b2d9..6bde7299657c 100644 --- a/lib/ssh/src/ssh_system_sup.erl +++ b/lib/ssh/src/ssh_system_sup.erl @@ -103,7 +103,7 @@ start_subsystem(Role, Address=#address{}, Socket, Options0) -> case supervisor:start_child(SysPid, #{id => Id, start => {ssh_subsystem_sup, start_link, - [Role,Address,Id,Socket,Options] + [Role,Id,Socket,Options] }, restart => temporary, significant => true, From 5710a69955ef83892d2e7c730c364994e14f185c Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Thu, 19 Sep 2024 11:48:23 +0200 Subject: [PATCH 2/3] ssh: do_start_subsystem added, skip system_sup for client --- lib/ssh/src/ssh.erl | 11 ++- lib/ssh/src/ssh_info.erl | 40 ++++++++--- lib/ssh/src/ssh_system_sup.erl | 126 +++++++++++++++++---------------- lib/ssh/test/ssh_sup_SUITE.erl | 31 ++++---- 4 files changed, 115 insertions(+), 93 deletions(-) diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl index f856d3d88787..714d4390f1e8 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -392,8 +392,7 @@ daemon(Host0, Port0, UserOptions0) when 0 =< Port0, Port0 =< 65535, %% throws error:Error if no usable hostkey is found ssh_connection_handler:available_hkey_algorithms(server, Options1), - ssh_system_sup:start_system(server, - #address{address = Host, + ssh_system_sup:start_system(#address{address = Host, port = Port, profile = ?GET_OPT(profile,Options1)}, Options1) @@ -540,8 +539,7 @@ stop_listener(Address, Port, Profile) -> lists:foreach(fun({Sup,_Addr}) -> stop_listener(Sup) end, - ssh_system_sup:addresses(server, - #address{address=Address, + ssh_system_sup:addresses(#address{address=Address, port=Port, profile=Profile})). @@ -552,7 +550,7 @@ stop_listener(Address, Port, Profile) -> -spec stop_daemon(DaemonRef::daemon_ref()) -> ok. stop_daemon(SysSup) -> - ssh_system_sup:stop_system(server, SysSup). + ssh_system_sup:stop_system(SysSup). -spec stop_daemon(inet:ip_address(), inet:port_number()) -> ok. @@ -567,8 +565,7 @@ stop_daemon(Address, Port, Profile) -> lists:foreach(fun({Sup,_Addr}) -> stop_daemon(Sup) end, - ssh_system_sup:addresses(server, - #address{address=Address, + ssh_system_sup:addresses(#address{address=Address, port=Port, profile=Profile})). diff --git a/lib/ssh/src/ssh_info.erl b/lib/ssh/src/ssh_info.erl index aa7324b58805..625d8109e1b7 100644 --- a/lib/ssh/src/ssh_info.erl +++ b/lib/ssh/src/ssh_info.erl @@ -131,13 +131,25 @@ format_sup(server, {{{ssh_system_sup,LocalAddress},Pid,supervisor,[ssh_system_su walk_tree(server, Children, ?inc(Indent)), io_lib:nl() % Separate system supervisors by an empty line ]; -format_sup(client, {{{ssh_system_sup,LocalAddress},Pid,supervisor,[ssh_system_sup]}, _Spec, Children}, Indent) -> - [indent(Indent), - io_lib:format("Local: ~s sys_sup=~s~n", [format_address(LocalAddress), print_pid(Pid)]), - walk_tree(client, Children, ?inc(Indent)), - io_lib:nl() % Separate system supervisors by an empty line +format_sup(client, + {{Ref,SubSysSup,supervisor,[ssh_subsystem_sup]}, _SubSysSpec, + [{{connection,ConnPid,worker,[ssh_connection_handler]}, _ConnSpec} + | Children] + }, + Indent) when is_reference(Ref) -> + [io_lib:format("~sLocal: ~s~n" + "~sRemote: ~s (Version: ~s)~n" + "~sConnectionRef=~s, subsys_sup=~s~n", + [indent(Indent), local_addr(ConnPid), + indent(Indent), peer_addr(ConnPid), peer_version(client,ConnPid), + indent(Indent), print_pid(ConnPid), print_pid(SubSysSup) + ]), + walk_tree(client, + [{H,{connref,ConnPid},Cs} || {H,_,Cs} <- Children], + ?inc(Indent)), + io_lib:nl() % Separate sub system supervisors by an empty line ]; -format_sup(Role, +format_sup(server, {{Ref,SubSysSup,supervisor,[ssh_subsystem_sup]}, _SubSysSpec, [{{connection,ConnPid,worker,[ssh_connection_handler]}, _ConnSpec} | Children] @@ -145,10 +157,10 @@ format_sup(Role, Indent) when is_reference(Ref) -> [io_lib:format("~sRemote: ~s (Version: ~s)~n" "~sConnectionRef=~s, subsys_sup=~s~n", - [indent(Indent), peer_addr(ConnPid), peer_version(Role,ConnPid), + [indent(Indent), peer_addr(ConnPid), peer_version(server,ConnPid), indent(Indent), print_pid(ConnPid), print_pid(SubSysSup) ]), - walk_tree(Role, + walk_tree(server, [{H,{connref,ConnPid},Cs} || {H,_,Cs} <- Children], ?inc(Indent)), io_lib:nl() % Separate sub system supervisors by an empty line @@ -250,7 +262,17 @@ peer_addr(Pid) -> catch _:_ -> "?" end. - + +local_addr(Pid) -> + try + [{socket,Socket}] = + ssh_connection_handler:connection_info(Pid, [socket]), + {ok, AddrPort} = inet:sockname(Socket), + ssh_lib:format_address_port(AddrPort) + catch + _:_ -> "?" + end. + format_address(#address{address=Addr, port=Port, profile=Prof}) -> io_lib:format("~s (profile ~p)", [ssh_lib:format_address_port({Addr,Port}),Prof]); diff --git a/lib/ssh/src/ssh_system_sup.erl b/lib/ssh/src/ssh_system_sup.erl index 6bde7299657c..799f262eef31 100644 --- a/lib/ssh/src/ssh_system_sup.erl +++ b/lib/ssh/src/ssh_system_sup.erl @@ -33,12 +33,11 @@ -export([start_link/3, stop_listener/1, - stop_system/2, - start_system/3, + stop_system/1, + start_system/2, start_subsystem/4, get_daemon_listen_address/1, addresses/1, - addresses/2, get_options/2, get_acceptor_options/1, replace_acceptor_options/2 @@ -51,28 +50,27 @@ %%% API %%%========================================================================= -start_system(Role, Address0, Options) -> - case find_system_sup(Role, Address0) of +start_system(Address0, Options) -> + case find_system_sup(Address0) of {ok,{SysPid,Address}} -> restart_acceptor(SysPid, Address, Options); {error,not_found} -> - supervisor:start_child(sup(Role), + supervisor:start_child(sshd_sup, #{id => {?MODULE,Address0}, - start => {?MODULE, start_link, [Role, Address0, Options]}, + start => {?MODULE, start_link, [server, Address0, Options]}, restart => temporary, type => supervisor }) end. %%%---------------------------------------------------------------- -stop_system(Role, SysSup) when is_pid(SysSup) -> - case lists:keyfind(SysSup, 2, supervisor:which_children(sup(Role))) of - {{?MODULE,Name}, SysSup, _, _} -> stop_system(Role, Name); - false -> undefind +stop_system(SysSup) when is_pid(SysSup) -> + case lists:keyfind(SysSup, 2, supervisor:which_children(sup(server))) of + {{?MODULE, Id}, SysSup, _, _} -> stop_system(Id); + false -> ok end; -stop_system(Role, Name) -> - supervisor:terminate_child(sup(Role), {?MODULE,Name}). - +stop_system(Id) -> + supervisor:terminate_child(sup(server), {?MODULE, Id}). %%%---------------------------------------------------------------- stop_listener(SystemSup) when is_pid(SystemSup) -> @@ -94,43 +92,49 @@ get_daemon_listen_address(SystemSup) -> end. %%%---------------------------------------------------------------- -%%% Start the subsystem child. It is a child of the system supervisor (callback = this module) -start_subsystem(Role, Address=#address{}, Socket, Options0) -> - Options = ?PUT_INTERNAL_OPT([{user_pid, self()}], Options0), +%%% Start the subsystem child. It is a significant child of the system +%%% supervisor (callback = this module) for server and non-significant +%%% child of sshc_sup for client +start_subsystem(Role = client, _, Socket, Options) -> + do_start_subsystem(Role, sup(client), false, Socket, Options); +start_subsystem(Role = server, Address=#address{}, Socket, Options) -> + case get_system_sup(Address, Options) of + {ok, SysPid} -> + do_start_subsystem(Role, SysPid, true, Socket, Options); + Others -> + Others + end. + +do_start_subsystem(Role, SupPid, Significant, Socket, Options0) -> Id = make_ref(), - case get_system_sup(Role, Address, Options) of - {ok,SysPid} -> - case supervisor:start_child(SysPid, - #{id => Id, - start => {ssh_subsystem_sup, start_link, - [Role,Id,Socket,Options] - }, - restart => temporary, - significant => true, - type => supervisor - }) - of - {ok,_SubSysPid} -> - try - receive - {new_connection_ref, Id, ConnPid} -> - ssh_connection_handler:takeover(ConnPid, Role, Socket, Options) - after 10000 -> - - error(timeout) - end - catch - error:{badmatch,{error,Error}} -> - {error,Error}; - error:timeout -> - %% The connection was started, but the takover procedure timed out, - %% therefore it exists a subtree, but it is not quite ready and - %% must be removed (by the supervisor above): - supervisor:terminate_child(SysPid, Id), - {error, connection_start_timeout} - end; - Others -> - Others + Options = ?PUT_INTERNAL_OPT([{user_pid, self()}], Options0), + case supervisor:start_child(SupPid, + #{id => Id, + start => {ssh_subsystem_sup, start_link, + [Role,Id,Socket,Options] + }, + restart => temporary, + significant => Significant, + type => supervisor + }) + of + {ok,_SubSysPid} -> + try + receive + {new_connection_ref, Id, ConnPid} -> + ssh_connection_handler:takeover(ConnPid, Role, Socket, Options) + after 10000 -> + error(timeout) + end + catch + error:{badmatch,{error,Error}} -> + {error,Error}; + error:timeout -> + %% The connection was started, but the takover procedure timed out, + %% therefore it exists a subtree, but it is not quite ready and + %% must be removed (by the supervisor above): + supervisor:terminate_child(SupPid, Id), + {error, connection_start_timeout} end; Others -> Others @@ -143,12 +147,9 @@ start_link(Role, Address, Options) -> %%%---------------------------------------------------------------- -addresses(Role) -> - addresses(Role, #address{address=any, port=any, profile=any}). - -addresses(Role, #address{address=Address, port=Port, profile=Profile}) -> - [{SysSup,A} || {{ssh_system_sup,A},SysSup,supervisor,_} <- - supervisor:which_children(sup(Role)), +addresses(#address{address=Address, port=Port, profile=Profile}) -> + [{SysSup,A} || {{ssh_system_sup,A},SysSup,supervisor,_} <- + supervisor:which_children(sshd_sup), Address == any orelse A#address.address == Address, Port == any orelse A#address.port == Port, Profile == any orelse A#address.profile == Profile]. @@ -233,19 +234,20 @@ lookup(SupModule, SystemSup) -> lists:keyfind([SupModule], 4, supervisor:which_children(SystemSup)). -get_system_sup(Role, Address0, Options) -> - case find_system_sup(Role, Address0) of +get_system_sup(Address0, Options) -> + case find_system_sup(Address0) of {ok,{SysPid,_Address}} -> {ok,SysPid}; {error,not_found} -> - start_system(Role, Address0, Options); + start_system(Address0, Options); {error,Error} -> {error,Error} end. -find_system_sup(Role, Address0) -> - case addresses(Role, Address0) of - [{SysSupPid,Address}] -> {ok,{SysSupPid,Address}}; +find_system_sup(Address0) -> + case addresses(Address0) of + [{SysSupPid,Address}] -> + {ok,{SysSupPid,Address}}; [] -> {error,not_found}; [_,_|_] -> {error,ambiguous} end. diff --git a/lib/ssh/test/ssh_sup_SUITE.erl b/lib/ssh/test/ssh_sup_SUITE.erl index 76f1cbe2c4a6..9dc9f74fc60e 100644 --- a/lib/ssh/test/ssh_sup_SUITE.erl +++ b/lib/ssh/test/ssh_sup_SUITE.erl @@ -131,26 +131,27 @@ sshc_subtree(Config) when is_list(Config) -> Pid1 = ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true}, {save_accepted_host, false}, - {user_interaction, false}, - {user, ?USER}, {password, ?PASSWD},{user_dir, UserDir}]), - - ?wait_match([?SYSTEM_SUP(SysSup, #address{address=LocalIP, port=LocalPort, profile=?DEFAULT_PROFILE}) - ], + {user_interaction, false}, + {user, ?USER}, + {password, ?PASSWD}, + {user_dir, UserDir}]), + ?wait_match([?SUB_SYSTEM_SUP(SubSysSup)], supervisor:which_children(sshc_sup), - [SysSup, LocalIP, LocalPort]), - check_sshc_system_tree(SysSup, Pid1, LocalIP, LocalPort, Config), - + [SubSysSup]), + check_sshc_system_tree(SubSysSup, Pid1, Config), Pid2 = ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true}, {save_accepted_host, false}, - {user_interaction, false}, - {user, ?USER}, {password, ?PASSWD}, {user_dir, UserDir}]), - ?wait_match([?SYSTEM_SUP(_,_), - ?SYSTEM_SUP(_,_) + {user_interaction, false}, + {user, ?USER}, + {password, ?PASSWD}, + {user_dir, UserDir}]), + ?wait_match([?SUB_SYSTEM_SUP(_), + ?SUB_SYSTEM_SUP(_) ], supervisor:which_children(sshc_sup)), ssh:close(Pid1), - ?wait_match([?SYSTEM_SUP(_,_) + ?wait_match([?SUB_SYSTEM_SUP(_) ], supervisor:which_children(sshc_sup)), ssh:close(Pid2), @@ -428,9 +429,9 @@ check_sshd_system_tree(Daemon, Host, Port, Config) -> ssh:close(ClientConn). -check_sshc_system_tree(SysSup, Connection, _LocalIP, _LocalPort, _Config) -> +check_sshc_system_tree(SubSysSup, Connection, _Config) -> ?wait_match([?SUB_SYSTEM_SUP(SubSysSup)], - supervisor:which_children(SysSup), + supervisor:which_children(sshc_sup), [SubSysSup]), ?wait_match([{_,FwdAccSup, supervisor,[ssh_tcpip_forward_acceptor_sup]}, {_,_,supervisor,[ssh_channel_sup]}, From 6b2e8e17e1f088bec8d312d0cdc607444b4c1a8c Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Thu, 19 Sep 2024 11:48:23 +0200 Subject: [PATCH 3/3] ssh: rename ssh_subsystem_sup to ssh_connection_sup - rename in order to improve supervision readability --- lib/ssh/src/Makefile | 2 +- lib/ssh/src/ssh.app.src | 4 +- lib/ssh/src/ssh.erl | 4 +- lib/ssh/src/ssh_acceptor.erl | 4 +- lib/ssh/src/ssh_connect.hrl | 2 +- lib/ssh/src/ssh_connection.erl | 20 ++--- lib/ssh/src/ssh_connection_handler.erl | 20 ++--- ...bsystem_sup.erl => ssh_connection_sup.erl} | 59 ++++++------- lib/ssh/src/ssh_info.erl | 10 +-- lib/ssh/src/ssh_system_sup.erl | 18 ++-- lib/ssh/test/ssh.cover | 2 +- lib/ssh/test/ssh_limited.cover | 2 +- lib/ssh/test/ssh_protocol_SUITE.erl | 2 +- lib/ssh/test/ssh_sup_SUITE.erl | 84 +++++++++---------- 14 files changed, 113 insertions(+), 120 deletions(-) rename lib/ssh/src/{ssh_subsystem_sup.erl => ssh_connection_sup.erl} (63%) diff --git a/lib/ssh/src/Makefile b/lib/ssh/src/Makefile index 2fcb1643013b..ee25174ed858 100644 --- a/lib/ssh/src/Makefile +++ b/lib/ssh/src/Makefile @@ -80,7 +80,7 @@ MODULES= \ ssh_sftpd \ ssh_sftpd_file\ ssh_shell \ - ssh_subsystem_sup \ + ssh_connection_sup \ ssh_system_sup \ ssh_tcpip_forward_srv \ ssh_tcpip_forward_client \ diff --git a/lib/ssh/src/ssh.app.src b/lib/ssh/src/ssh.app.src index 2cb8d8048882..4ce8fee692cf 100644 --- a/lib/ssh/src/ssh.app.src +++ b/lib/ssh/src/ssh.app.src @@ -36,7 +36,7 @@ ssh_sftpd, ssh_sftpd_file, ssh_sftpd_file_api, - ssh_subsystem_sup, + ssh_connection_sup, ssh_tcpip_forward_client, ssh_tcpip_forward_srv, ssh_tcpip_forward_acceptor_sup, @@ -51,7 +51,7 @@ ssh_acceptor, ssh_channel_sup, ssh_connection_handler, - ssh_subsystem_sup, + ssh_connection_sup, ssh_system_sup ]}, {default_filter, rm} %% rm | filter diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl index 714d4390f1e8..052f5efa8842 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -248,7 +248,7 @@ continue_connect(Socket, Options0, NegTimeout) -> port = SockPort, profile = ?GET_OPT(profile,Options) }, - ssh_system_sup:start_subsystem(client, Address, Socket, Options). + ssh_system_sup:start_connection(client, Address, Socket, Options). %%-------------------------------------------------------------------- -spec close(ConnectionRef) -> ok | {error,term()} when @@ -343,7 +343,7 @@ daemon(Socket, UserOptions) -> profile = ?GET_OPT(profile,Options0) }, Options = ?PUT_INTERNAL_OPT({connected_socket, Socket}, Options0), - case ssh_system_sup:start_subsystem(server, Address, Socket, Options) of + case ssh_system_sup:start_connection(server, Address, Socket, Options) of {ok,Pid} -> {ok,Pid}; {error, {already_started, _}} -> diff --git a/lib/ssh/src/ssh_acceptor.erl b/lib/ssh/src/ssh_acceptor.erl index 00587eecbae1..54bebd12d34c 100644 --- a/lib/ssh/src/ssh_acceptor.erl +++ b/lib/ssh/src/ssh_acceptor.erl @@ -187,7 +187,7 @@ handle_connection(Address, Port, _Peer, Options, Socket, _MaxSessions, _NumSessi handle_connection(Address, Port, Options0, Socket) -> Options = ?PUT_INTERNAL_OPT([{user_pid, self()} ], Options0), - ssh_system_sup:start_subsystem(server, + ssh_system_sup:start_connection(server, #address{address = Address, port = Port, profile = ?GET_OPT(profile,Options) @@ -243,7 +243,7 @@ handle_error(Reason, ToAddress, ToPort, FromAddress, FromPort) -> %%%---------------------------------------------------------------- number_of_connections(SysSupPid) -> - lists:foldl(fun({_Ref,_Pid,supervisor,[ssh_subsystem_sup]}, N) -> N+1; + lists:foldl(fun({_Ref,_Pid,supervisor,[ssh_connection_sup]}, N) -> N+1; (_, N) -> N end, 0, supervisor:which_children(SysSupPid)). diff --git a/lib/ssh/src/ssh_connect.hrl b/lib/ssh/src/ssh_connect.hrl index 3bd53d59126a..4c6fdaefd4c3 100644 --- a/lib/ssh/src/ssh_connect.hrl +++ b/lib/ssh/src/ssh_connect.hrl @@ -269,5 +269,5 @@ suggest_window_size, suggest_packet_size, exec, - sub_system_supervisor + connection_supervisor }). diff --git a/lib/ssh/src/ssh_connection.erl b/lib/ssh/src/ssh_connection.erl index 34e97ba6ca1f..40096e1227c4 100644 --- a/lib/ssh/src/ssh_connection.erl +++ b/lib/ssh/src/ssh_connection.erl @@ -606,7 +606,7 @@ handle_msg(#ssh_msg_channel_open{channel_type = "forwarded-tcpip", suggest_window_size = WinSz, suggest_packet_size = PktSz, options = Options, - sub_system_supervisor = SubSysSup + connection_supervisor = ConnectionSup } = C, client, _SSH) -> {ReplyMsg, NextChId} = @@ -614,7 +614,7 @@ handle_msg(#ssh_msg_channel_open{channel_type = "forwarded-tcpip", {ok, {ConnectToHost,ConnectToPort}} -> case gen_tcp:connect(ConnectToHost, ConnectToPort, [{active,false}, binary]) of {ok,Sock} -> - {ok,Pid} = ssh_subsystem_sup:start_channel(client, SubSysSup, self(), + {ok,Pid} = ssh_connection_sup:start_channel(client, ConnectionSup, self(), ssh_tcpip_forward_client, ChId, [Sock], undefined, Options), ssh_client_channel:cache_update(Cache, @@ -664,7 +664,7 @@ handle_msg(#ssh_msg_channel_open{channel_type = "direct-tcpip", suggest_window_size = WinSz, suggest_packet_size = PktSz, options = Options, - sub_system_supervisor = SubSysSup + connection_supervisor = ConnectionSup } = C, server, _SSH) -> {ReplyMsg, NextChId} = @@ -680,7 +680,7 @@ handle_msg(#ssh_msg_channel_open{channel_type = "direct-tcpip", case gen_tcp:connect(binary_to_list(HostToConnect), PortToConnect, [{active,false}, binary]) of {ok,Sock} -> - {ok,Pid} = ssh_subsystem_sup:start_channel(server, SubSysSup, self(), + {ok,Pid} = ssh_connection_sup:start_channel(server, ConnectionSup, self(), ssh_tcpip_forward_srv, ChId, [Sock], undefined, Options), ssh_client_channel:cache_update(Cache, @@ -912,8 +912,8 @@ handle_msg(#ssh_msg_global_request{name = <<"tcpip-forward">>, {[{connection_reply, request_failure_msg()}], Connection}; true -> - SubSysSup = ?GET_INTERNAL_OPT(subsystem_sup, Opts), - FwdSup = ssh_subsystem_sup:tcpip_fwd_supervisor(SubSysSup), + ConnectionSup = ?GET_INTERNAL_OPT(connection_sup, Opts), + FwdSup = ssh_connection_sup:tcpip_fwd_supervisor(ConnectionSup), ConnPid = self(), case ssh_tcpip_forward_acceptor:supervised_start(FwdSup, {ListenAddrStr, ListenPort}, @@ -1127,22 +1127,22 @@ setup_session(#connection{channel_cache = Cache, start_cli(#connection{options = Options, cli_spec = CliSpec, exec = Exec, - sub_system_supervisor = SubSysSup}, ChannelId) -> + connection_supervisor = ConnectionSup}, ChannelId) -> case CliSpec of no_cli -> {error, cli_disabled}; {CbModule, Args} -> - ssh_subsystem_sup:start_channel(server, SubSysSup, self(), CbModule, ChannelId, Args, Exec, Options) + ssh_connection_sup:start_channel(server, ConnectionSup, self(), CbModule, ChannelId, Args, Exec, Options) end. start_subsystem(BinName, #connection{options = Options, - sub_system_supervisor = SubSysSup}, + connection_supervisor = ConnectionSup}, #channel{local_id = ChannelId}, _ReplyMsg) -> Name = binary_to_list(BinName), case check_subsystem(Name, Options) of {Callback, Opts} when is_atom(Callback), Callback =/= none -> - ssh_subsystem_sup:start_channel(server, SubSysSup, self(), Callback, ChannelId, Opts, undefined, Options); + ssh_connection_sup:start_channel(server, ConnectionSup, self(), Callback, ChannelId, Opts, undefined, Options); {none, _} -> {error, bad_subsystem}; {_, _} -> diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl index 93fd84c63d7f..162ceccfd594 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -110,7 +110,7 @@ start_link(Role, Id, Socket, Options) -> %% Announce the ConnectionRef to the system supervisor so it could %% 1) initiate the socket handover, and %% 2) be returned to whoever called for example ssh:connect; the Pid - %% returned from this function is "consumed" by the subsystem + %% returned from this function is "consumed" by the connection %% supervisor. ?GET_INTERNAL_OPT(user_pid,Options) ! {new_connection_ref, Id, Pid}, {ok, Pid}; @@ -195,8 +195,8 @@ open_channel(ConnectionHandler, %% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . start_channel(ConnectionHandler, CallbackModule, ChannelId, Args, Exec) -> - {ok, {SubSysSup,Role,Opts}} = call(ConnectionHandler, get_misc), - ssh_subsystem_sup:start_channel(Role, SubSysSup, + {ok, {ConnectionSup,Role,Opts}} = call(ConnectionHandler, get_misc), + ssh_connection_sup:start_channel(Role, ConnectionSup, ConnectionHandler, CallbackModule, ChannelId, Args, Exec, Opts). @@ -435,7 +435,7 @@ init_connection_record(Role, Socket, Opts) -> suggest_packet_size = PktSz, requests = [], options = Opts, - sub_system_supervisor = ?GET_INTERNAL_OPT(subsystem_sup, Opts) + connection_supervisor = ?GET_INTERNAL_OPT(connection_sup, Opts) }, case Role of server -> @@ -1002,8 +1002,8 @@ handle_event({call,From}, {eof, ChannelId}, StateName, D0) handle_event({call,From}, get_misc, StateName, #data{connection_state = #connection{options = Opts}} = D) when ?CONNECTED(StateName) -> - SubSysSup = ?GET_INTERNAL_OPT(subsystem_sup, Opts), - Reply = {ok, {SubSysSup, ?role(StateName), Opts}}, + ConnectionSup = ?GET_INTERNAL_OPT(connection_sup, Opts), + Reply = {ok, {ConnectionSup, ?role(StateName), Opts}}, {keep_state, D, [{reply,From,Reply}]}; handle_event({call,From}, @@ -1266,9 +1266,9 @@ handle_event(info, check_cache, _, D) -> handle_event(info, {fwd_connect_received, Sock, ChId, ChanCB}, StateName, #data{connection_state = Connection}) -> #connection{options = Options, channel_cache = Cache, - sub_system_supervisor = SubSysSup} = Connection, + connection_supervisor = ConnectionSup} = Connection, Channel = ssh_client_channel:cache_lookup(Cache, ChId), - {ok,Pid} = ssh_subsystem_sup:start_channel(?role(StateName), SubSysSup, self(), ChanCB, ChId, [Sock], undefined, Options), + {ok,Pid} = ssh_connection_sup:start_channel(?role(StateName), ConnectionSup, self(), ChanCB, ChId, [Sock], undefined, Options), ssh_client_channel:cache_update(Cache, Channel#channel{user=Pid}), gen_tcp:controlling_process(Sock, Pid), inet:setopts(Sock, [{active,once}]), @@ -1277,8 +1277,8 @@ handle_event(info, {fwd_connect_received, Sock, ChId, ChanCB}, StateName, #data{ handle_event({call,From}, {handle_direct_tcpip, ListenHost, ListenPort, ConnectToHost, ConnectToPort, _Timeout}, _StateName, - #data{connection_state = #connection{sub_system_supervisor=SubSysSup}}) -> - case ssh_tcpip_forward_acceptor:supervised_start(ssh_subsystem_sup:tcpip_fwd_supervisor(SubSysSup), + #data{connection_state = #connection{connection_supervisor=ConnectionSup}}) -> + case ssh_tcpip_forward_acceptor:supervised_start(ssh_connection_sup:tcpip_fwd_supervisor(ConnectionSup), {ListenHost, ListenPort}, {ConnectToHost, ConnectToPort}, "direct-tcpip", ssh_tcpip_forward_client, diff --git a/lib/ssh/src/ssh_subsystem_sup.erl b/lib/ssh/src/ssh_connection_sup.erl similarity index 63% rename from lib/ssh/src/ssh_subsystem_sup.erl rename to lib/ssh/src/ssh_connection_sup.erl index 2eb61c6236bd..2774e4a7a44e 100644 --- a/lib/ssh/src/ssh_subsystem_sup.erl +++ b/lib/ssh/src/ssh_connection_sup.erl @@ -19,10 +19,10 @@ %% %% %%---------------------------------------------------------------------- -%% Purpose: The ssh subsystem supervisor +%% Purpose: The ssh connection supervisor %%---------------------------------------------------------------------- --module(ssh_subsystem_sup). +-module(ssh_connection_sup). -behaviour(supervisor). @@ -51,51 +51,46 @@ start_channel(Role, SupPid, ConnRef, Callback, Id, Args, Exec, Opts) -> ChannelSup = channel_supervisor(SupPid), ssh_channel_sup:start_child(Role, ChannelSup, ConnRef, Callback, Id, Args, Exec, Opts). -tcpip_fwd_supervisor(SubSysSup) -> - find_child(tcpip_forward_acceptor_sup, SubSysSup). +tcpip_fwd_supervisor(ConnectionSup) -> + find_child(tcpip_forward_acceptor_sup, ConnectionSup). %%%========================================================================= %%% Supervisor callback %%%========================================================================= init([Role, Id, Socket, Options]) -> - SubSysSup = self(), + ConnectionSup = self(), SupFlags = #{strategy => one_for_all, auto_shutdown => any_significant, intensity => 0, - period => 3600 - }, - ChildSpecs = [#{id => connection, - restart => temporary, - type => worker, - significant => true, - start => {ssh_connection_handler, - start_link, - [Role, Id, Socket, - ?PUT_INTERNAL_OPT([ - {subsystem_sup, SubSysSup} - ], Options) - ] - } - }, - #{id => channel_sup, - restart => temporary, - type => supervisor, - start => {ssh_channel_sup, start_link, [Options]} - }, + period => 3600}, + ChildSpecs = + [#{id => connection, + restart => temporary, + type => worker, + significant => true, + start => {ssh_connection_handler, + start_link, + [Role, Id, Socket, + ?PUT_INTERNAL_OPT([{connection_sup, ConnectionSup}], Options)]} + }, + #{id => channel_sup, + restart => temporary, + type => supervisor, + start => {ssh_channel_sup, start_link, [Options]} + }, - #{id => tcpip_forward_acceptor_sup, - restart => temporary, - type => supervisor, - start => {ssh_tcpip_forward_acceptor_sup, start_link, []} - } - ], + #{id => tcpip_forward_acceptor_sup, + restart => temporary, + type => supervisor, + start => {ssh_tcpip_forward_acceptor_sup, start_link, []} + }], {ok, {SupFlags,ChildSpecs}}. %%%========================================================================= %%% Internal functions %%%========================================================================= -channel_supervisor(SubSysSup) -> find_child(channel_sup, SubSysSup). +channel_supervisor(ConnectionSup) -> find_child(channel_sup, ConnectionSup). find_child(Id, Sup) when is_pid(Sup) -> try diff --git a/lib/ssh/src/ssh_info.erl b/lib/ssh/src/ssh_info.erl index 625d8109e1b7..365357b4d566 100644 --- a/lib/ssh/src/ssh_info.erl +++ b/lib/ssh/src/ssh_info.erl @@ -132,7 +132,7 @@ format_sup(server, {{{ssh_system_sup,LocalAddress},Pid,supervisor,[ssh_system_su io_lib:nl() % Separate system supervisors by an empty line ]; format_sup(client, - {{Ref,SubSysSup,supervisor,[ssh_subsystem_sup]}, _SubSysSpec, + {{Ref,ConnSup,supervisor,[ssh_connection_sup]}, _ConnSupSpec, [{{connection,ConnPid,worker,[ssh_connection_handler]}, _ConnSpec} | Children] }, @@ -142,7 +142,7 @@ format_sup(client, "~sConnectionRef=~s, subsys_sup=~s~n", [indent(Indent), local_addr(ConnPid), indent(Indent), peer_addr(ConnPid), peer_version(client,ConnPid), - indent(Indent), print_pid(ConnPid), print_pid(SubSysSup) + indent(Indent), print_pid(ConnPid), print_pid(ConnSup) ]), walk_tree(client, [{H,{connref,ConnPid},Cs} || {H,_,Cs} <- Children], @@ -150,15 +150,15 @@ format_sup(client, io_lib:nl() % Separate sub system supervisors by an empty line ]; format_sup(server, - {{Ref,SubSysSup,supervisor,[ssh_subsystem_sup]}, _SubSysSpec, - [{{connection,ConnPid,worker,[ssh_connection_handler]}, _ConnSpec} + {{Ref,ConnSup,supervisor,[ssh_connection_sup]}, _ConnSupSpec, + [{{connection,ConnPid,worker,[ssh_connection_handler]}, _ConnSpec} | Children] }, Indent) when is_reference(Ref) -> [io_lib:format("~sRemote: ~s (Version: ~s)~n" "~sConnectionRef=~s, subsys_sup=~s~n", [indent(Indent), peer_addr(ConnPid), peer_version(server,ConnPid), - indent(Indent), print_pid(ConnPid), print_pid(SubSysSup) + indent(Indent), print_pid(ConnPid), print_pid(ConnSup) ]), walk_tree(server, [{H,{connref,ConnPid},Cs} || {H,_,Cs} <- Children], diff --git a/lib/ssh/src/ssh_system_sup.erl b/lib/ssh/src/ssh_system_sup.erl index 799f262eef31..8e0bc75df7ca 100644 --- a/lib/ssh/src/ssh_system_sup.erl +++ b/lib/ssh/src/ssh_system_sup.erl @@ -35,7 +35,7 @@ stop_listener/1, stop_system/1, start_system/2, - start_subsystem/4, + start_connection/4, get_daemon_listen_address/1, addresses/1, get_options/2, @@ -92,25 +92,25 @@ get_daemon_listen_address(SystemSup) -> end. %%%---------------------------------------------------------------- -%%% Start the subsystem child. It is a significant child of the system +%%% Start the connection child. It is a significant child of the system %%% supervisor (callback = this module) for server and non-significant %%% child of sshc_sup for client -start_subsystem(Role = client, _, Socket, Options) -> - do_start_subsystem(Role, sup(client), false, Socket, Options); -start_subsystem(Role = server, Address=#address{}, Socket, Options) -> +start_connection(Role = client, _, Socket, Options) -> + do_start_connection(Role, sup(client), false, Socket, Options); +start_connection(Role = server, Address=#address{}, Socket, Options) -> case get_system_sup(Address, Options) of {ok, SysPid} -> - do_start_subsystem(Role, SysPid, true, Socket, Options); + do_start_connection(Role, SysPid, true, Socket, Options); Others -> Others end. -do_start_subsystem(Role, SupPid, Significant, Socket, Options0) -> +do_start_connection(Role, SupPid, Significant, Socket, Options0) -> Id = make_ref(), Options = ?PUT_INTERNAL_OPT([{user_pid, self()}], Options0), case supervisor:start_child(SupPid, #{id => Id, - start => {ssh_subsystem_sup, start_link, + start => {ssh_connection_sup, start_link, [Role,Id,Socket,Options] }, restart => temporary, @@ -118,7 +118,7 @@ do_start_subsystem(Role, SupPid, Significant, Socket, Options0) -> type => supervisor }) of - {ok,_SubSysPid} -> + {ok,_ConnectionSupPid} -> try receive {new_connection_ref, Id, ConnPid} -> diff --git a/lib/ssh/test/ssh.cover b/lib/ssh/test/ssh.cover index daf6c723b9b9..c4cac8daf5be 100644 --- a/lib/ssh/test/ssh.cover +++ b/lib/ssh/test/ssh.cover @@ -7,7 +7,7 @@ %% %% Supervisors %% ssh_acceptor_sup, ssh_channel_sup, - %% sshc_sup, sshd_sup, ssh_subsystem_sup, ssh_sup, + %% sshc_sup, sshd_sup, ssh_connection_sup, ssh_sup, %% ssh_system_sup, ssh_tcpip_forward_acceptor_sup, %% Test and/or info modules: diff --git a/lib/ssh/test/ssh_limited.cover b/lib/ssh/test/ssh_limited.cover index 29c0121ae1ff..64904c9ce737 100644 --- a/lib/ssh/test/ssh_limited.cover +++ b/lib/ssh/test/ssh_limited.cover @@ -9,7 +9,7 @@ %% Supervisors ssh_acceptor_sup, ssh_channel_sup, - sshc_sup, sshd_sup, ssh_subsystem_sup, ssh_sup, + sshc_sup, sshd_sup, ssh_connection_sup, ssh_sup, ssh_system_sup, ssh_tcpip_forward_acceptor_sup, %% Test and/or info modules: diff --git a/lib/ssh/test/ssh_protocol_SUITE.erl b/lib/ssh/test/ssh_protocol_SUITE.erl index 666ac76f6334..7a99976e3131 100644 --- a/lib/ssh/test/ssh_protocol_SUITE.erl +++ b/lib/ssh/test/ssh_protocol_SUITE.erl @@ -1177,7 +1177,7 @@ find_handshake_parent([{{ssh_acceptor_sup,{address,_,Port,_}}, {Parents,Handshakers} = lists:unzip(ParentHandshakers), find_handshake_parent(T, Port, {AccP++Parents, AccC, AccH++Handshakers}); -find_handshake_parent([{_Ref,PidS,supervisor,[ssh_subsystem_sup]}|T], Port, {AccP,AccC,AccH}) -> +find_handshake_parent([{_Ref,PidS,supervisor,[ssh_connection_sup]}|T], Port, {AccP,AccC,AccH}) -> Connections = [Pid || {connection,Pid,worker,[ssh_connection_handler]} <- supervisor:which_children(PidS)], find_handshake_parent(T, Port, {AccP, AccC++Connections, AccH}); diff --git a/lib/ssh/test/ssh_sup_SUITE.erl b/lib/ssh/test/ssh_sup_SUITE.erl index 9dc9f74fc60e..d76ce9edf6d5 100644 --- a/lib/ssh/test/ssh_sup_SUITE.erl +++ b/lib/ssh/test/ssh_sup_SUITE.erl @@ -52,10 +52,13 @@ -define(SSHC_SUP(Pid), {sshc_sup, Pid, supervisor, [supervisor]}). -define(SSHD_SUP(Pid), {sshd_sup, Pid, supervisor, [supervisor]}). --define(SYSTEM_SUP(Pid,Address), {{ssh_system_sup, Address}, Pid, supervisor,[ssh_system_sup]}). --define(SUB_SYSTEM_SUP(Pid), {_,Pid, supervisor,[ssh_subsystem_sup]}). --define(ACCEPTOR_SUP(Pid,Address), {{ssh_acceptor_sup,Address},Pid,supervisor,[ssh_acceptor_sup]}). --define(ACCEPTOR_WORKER(Pid,Address), {{ssh_acceptor_sup,Address},Pid,worker,[ssh_acceptor]}). +-define(SYSTEM_SUP(Pid,Address), + {{ssh_system_sup, Address}, Pid, supervisor,[ssh_system_sup]}). +-define(CONNECTION_SUP(Pid), {_,Pid, supervisor,[ssh_connection_sup]}). +-define(ACCEPTOR_SUP(Pid,Address), + {{ssh_acceptor_sup,Address},Pid,supervisor,[ssh_acceptor_sup]}). +-define(ACCEPTOR_WORKER(Pid,Address), + {{ssh_acceptor_sup,Address},Pid,worker,[ssh_acceptor]}). %%-------------------------------------------------------------------- %% Common Test interface functions ----------------------------------- @@ -135,23 +138,23 @@ sshc_subtree(Config) when is_list(Config) -> {user, ?USER}, {password, ?PASSWD}, {user_dir, UserDir}]), - ?wait_match([?SUB_SYSTEM_SUP(SubSysSup)], + ?wait_match([?CONNECTION_SUP(ConnectionSup)], supervisor:which_children(sshc_sup), - [SubSysSup]), - check_sshc_system_tree(SubSysSup, Pid1, Config), + [ConnectionSup]), + check_sshc_system_tree(ConnectionSup, Pid1, Config), Pid2 = ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true}, {save_accepted_host, false}, {user_interaction, false}, {user, ?USER}, {password, ?PASSWD}, {user_dir, UserDir}]), - ?wait_match([?SUB_SYSTEM_SUP(_), - ?SUB_SYSTEM_SUP(_) + ?wait_match([?CONNECTION_SUP(_), + ?CONNECTION_SUP(_) ], supervisor:which_children(sshc_sup)), ssh:close(Pid1), - ?wait_match([?SUB_SYSTEM_SUP(_) + ?wait_match([?CONNECTION_SUP(_) ], supervisor:which_children(sshc_sup)), ssh:close(Pid2), @@ -305,8 +308,8 @@ shell_channel_tree(Config) -> {user_interaction, true}, {user_dir, UserDir}]), - [SubSysSup,_ChPid|_] = Sups0 = chk_empty_con_daemon(Daemon), - + [ConnectionSup,_ChPid|_] = Sups0 = chk_empty_con_daemon(Daemon), + {ok, ChannelId0} = ssh_connection:session_channel(ConnectionRef, infinity), ok = ssh_connection:shell(ConnectionRef,ChannelId0), success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId0, [{pty_opts,[{onlcr,1}]}]), @@ -315,7 +318,7 @@ shell_channel_tree(Config) -> {_,ChSup,supervisor,[ssh_channel_sup]}, {connection,_,worker,[ssh_connection_handler]} ], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [ChSup]), ?wait_match([{_,GroupPid,worker,[ssh_server_channel]} ], @@ -332,9 +335,9 @@ shell_channel_tree(Config) -> {ssh_cm,ConnectionRef, {data, ChannelId0, 0, <<"TimeoutShell started!",Rest/binary>>}} -> ct:log("TimeoutShell started. Rest = ~p", [Rest]), receive - %%---- wait for the subsystem to terminate + %%---- wait for the connection to terminate {ssh_cm,ConnectionRef,{closed,ChannelId0}} -> - ct:log("Subsystem terminated",[]), + ct:log("Connection terminated",[]), case {chk_empty_con_daemon(Daemon), process_info(GroupPid), process_info(ShellPid)} of @@ -365,23 +368,23 @@ shell_channel_tree(Config) -> end. chk_empty_con_daemon(Daemon) -> - ?wait_match([?SUB_SYSTEM_SUP(SubSysSup), + ?wait_match([?CONNECTION_SUP(ConnectionSup), ?ACCEPTOR_SUP(AccSup,_) ], supervisor:which_children(Daemon), - [SubSysSup,AccSup]), + [ConnectionSup,AccSup]), ?wait_match([{_,FwdAccSup, supervisor,[ssh_tcpip_forward_acceptor_sup]}, {_,ChSup,supervisor,[ssh_channel_sup]}, {connection,ServerConnPid,worker,[ssh_connection_handler]} ], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [ChSup,FwdAccSup,ServerConnPid]), ?wait_match([], supervisor:which_children(FwdAccSup)), ?wait_match([], supervisor:which_children(ChSup)), ?wait_match([?ACCEPTOR_WORKER(_,_)], supervisor:which_children(AccSup), []), - [SubSysSup, ChSup, ServerConnPid, AccSup, FwdAccSup]. + [ConnectionSup, ChSup, ServerConnPid, AccSup, FwdAccSup]. %%------------------------------------------------------------------------- %% Help functions @@ -389,22 +392,18 @@ chk_empty_con_daemon(Daemon) -> check_sshd_system_tree(Daemon, Host, Port, Config) -> UserDir = proplists:get_value(userdir, Config), ClientConn = ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true}, - {user_interaction, false}, - {user, ?USER}, - {password, ?PASSWD}, - {user_dir, UserDir}]), - - ?wait_match([?SUB_SYSTEM_SUP(SubSysSup), - ?ACCEPTOR_SUP(AccSup,_) - ], + {user_interaction, false}, + {user, ?USER}, + {password, ?PASSWD}, + {user_dir, UserDir}]), + ?wait_match([?CONNECTION_SUP(ConnectionSup), + ?ACCEPTOR_SUP(AccSup,_)], supervisor:which_children(Daemon), - [SubSysSup,AccSup]), - + [ConnectionSup,AccSup]), ?wait_match([{_,FwdAccSup, supervisor,[ssh_tcpip_forward_acceptor_sup]}, {_,_,supervisor,[ssh_channel_sup]}, - {connection,ServerConn,worker,[ssh_connection_handler]} - ], - supervisor:which_children(SubSysSup), + {connection,ServerConn,worker,[ssh_connection_handler]}], + supervisor:which_children(ConnectionSup), [FwdAccSup,ServerConn]), ?wait_match([], supervisor:which_children(FwdAccSup)), @@ -415,9 +414,8 @@ check_sshd_system_tree(Daemon, Host, Port, Config) -> {ok,PidC} = ssh_sftp:start_channel(ClientConn), ?wait_match([{_,FwdAccSup, supervisor,[ssh_tcpip_forward_acceptor_sup]}, {_,ChSup,supervisor,[ssh_channel_sup]}, - {connection,ServerConn,worker,[ssh_connection_handler]} - ], - supervisor:which_children(SubSysSup), + {connection,ServerConn,worker,[ssh_connection_handler]}], + supervisor:which_children(ConnectionSup), [ChSup,ServerConn]), ?wait_match([{_,PidS,worker,[ssh_server_channel]}], @@ -429,15 +427,15 @@ check_sshd_system_tree(Daemon, Host, Port, Config) -> ssh:close(ClientConn). -check_sshc_system_tree(SubSysSup, Connection, _Config) -> - ?wait_match([?SUB_SYSTEM_SUP(SubSysSup)], +check_sshc_system_tree(ConnectionSup, Connection, _Config) -> + ?wait_match([?CONNECTION_SUP(ConnectionSup)], supervisor:which_children(sshc_sup), - [SubSysSup]), + [ConnectionSup]), ?wait_match([{_,FwdAccSup, supervisor,[ssh_tcpip_forward_acceptor_sup]}, {_,_,supervisor,[ssh_channel_sup]}, {connection,Connection,worker,[ssh_connection_handler]} ], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [FwdAccSup]), ?wait_match([], supervisor:which_children(FwdAccSup)), @@ -446,7 +444,7 @@ check_sshc_system_tree(SubSysSup, Connection, _Config) -> {_,ChSup,supervisor, [ssh_channel_sup]}, {connection,Connection,worker,[ssh_connection_handler]} ], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [ChSup,FwdAccSup]), ?wait_match([{_,ChPid1,worker,[ssh_client_channel]} @@ -459,7 +457,7 @@ check_sshc_system_tree(SubSysSup, Connection, _Config) -> {_,ChSup,supervisor, [ssh_channel_sup]}, {connection,Connection,worker,[ssh_connection_handler]} ], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [ChSup,FwdAccSup]), ?wait_match([{_,ChPid2,worker,[ssh_client_channel]}, @@ -474,7 +472,7 @@ check_sshc_system_tree(SubSysSup, Connection, _Config) -> {_,ChSup,supervisor, [ssh_channel_sup]}, {connection,Connection,worker,[ssh_connection_handler]} ], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [ChSup,FwdAccSup]), ?wait_match([{_,ChPid2,worker,[ssh_client_channel]} @@ -488,7 +486,7 @@ check_sshc_system_tree(SubSysSup, Connection, _Config) -> {_,ChSup,supervisor, [ssh_channel_sup]}, {connection,Connection,worker,[ssh_connection_handler]} ], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [ChSup,FwdAccSup]), ?wait_match([], supervisor:which_children(ChSup)),