From 5862f24dd160fb12ad59f40a9de5d6e848c6b16c Mon Sep 17 00:00:00 2001 From: Jakub Witczak Date: Thu, 19 Sep 2024 11:48:23 +0200 Subject: [PATCH] ssh: rename ssh_subsystem_sup to ssh_connection_sup - rename in order to improve supervision readability --- .../test/compile_SUITE_data/ssh_connect.hrl | 2 +- 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} | 61 +++++++++---------- 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 | 54 ++++++++-------- 15 files changed, 101 insertions(+), 106 deletions(-) rename lib/ssh/src/{ssh_subsystem_sup.erl => ssh_connection_sup.erl} (62%) diff --git a/lib/compiler/test/compile_SUITE_data/ssh_connect.hrl b/lib/compiler/test/compile_SUITE_data/ssh_connect.hrl index 3165588c68df..07bbf6005f68 100644 --- a/lib/compiler/test/compile_SUITE_data/ssh_connect.hrl +++ b/lib/compiler/test/compile_SUITE_data/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/Makefile b/lib/ssh/src/Makefile index 5fba21655d30..a8a088eb7daf 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 eb31e69db89e..93f4c2b305bf 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 d7fa6f72ad08..7f6d5ea02fb0 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -414,7 +414,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). %%-------------------------------------------------------------------- -doc "Closes an SSH connection.". @@ -532,7 +532,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 32f1406fa2d2..1831e32f6cd4 100644 --- a/lib/ssh/src/ssh_acceptor.erl +++ b/lib/ssh/src/ssh_acceptor.erl @@ -191,7 +191,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) @@ -247,7 +247,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 8849f29575cc..424a6e25837c 100644 --- a/lib/ssh/src/ssh_connection.erl +++ b/lib/ssh/src/ssh_connection.erl @@ -886,7 +886,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} = @@ -894,7 +894,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, @@ -944,7 +944,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} = @@ -960,7 +960,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, @@ -1192,8 +1192,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}, @@ -1423,22 +1423,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 643d05f69db1..1c25e171ba5b 100644 --- a/lib/ssh/src/ssh_connection_handler.erl +++ b/lib/ssh/src/ssh_connection_handler.erl @@ -111,7 +111,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}; @@ -197,8 +197,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). @@ -418,7 +418,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 -> @@ -1022,8 +1022,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}, @@ -1286,9 +1286,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}]), @@ -1297,8 +1297,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 62% rename from lib/ssh/src/ssh_subsystem_sup.erl rename to lib/ssh/src/ssh_connection_sup.erl index e6419acfc56e..db410cf7e5f4 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). -moduledoc false. -behaviour(supervisor). @@ -52,52 +52,47 @@ 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]) -> - ssh_lib:set_label(Role, {subsystem_sup, Socket}), - SubSysSup = self(), + ssh_lib:set_label(Role, {connection_sup, Socket}), + 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 bcf34f7e7306..10c3a0e07c89 100644 --- a/lib/ssh/src/ssh_info.erl +++ b/lib/ssh/src/ssh_info.erl @@ -133,7 +133,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] }, @@ -143,7 +143,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], @@ -151,15 +151,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 6435f2692c83..bc1d79d0f49a 100644 --- a/lib/ssh/src/ssh_system_sup.erl +++ b/lib/ssh/src/ssh_system_sup.erl @@ -36,7 +36,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, @@ -94,25 +94,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, @@ -120,7 +120,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 aca777774a72..425d78f20b4e 100644 --- a/lib/ssh/test/ssh_protocol_SUITE.erl +++ b/lib/ssh/test/ssh_protocol_SUITE.erl @@ -1259,7 +1259,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 66b5fd8c0bc4..ca85bcd99a7e 100644 --- a/lib/ssh/test/ssh_sup_SUITE.erl +++ b/lib/ssh/test/ssh_sup_SUITE.erl @@ -50,7 +50,7 @@ -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(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), @@ -129,22 +129,22 @@ 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), @@ -298,7 +298,7 @@ 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), @@ -308,7 +308,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]} ], @@ -325,9 +325,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 @@ -358,23 +358,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 @@ -386,14 +386,14 @@ check_sshd_system_tree(Daemon, Host, Port, Config) -> {user, ?USER}, {password, ?PASSWD}, {user_dir, UserDir}]), - ?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]}, {_,_,supervisor,[ssh_channel_sup]}, {connection,ServerConn,worker,[ssh_connection_handler]}], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [FwdAccSup,ServerConn]), ?wait_match([], supervisor:which_children(FwdAccSup)), ?wait_match([?ACCEPTOR_WORKER(_,_)], supervisor:which_children(AccSup)), @@ -401,7 +401,7 @@ check_sshd_system_tree(Daemon, Host, Port, Config) -> ?wait_match([{_,FwdAccSup, supervisor,[ssh_tcpip_forward_acceptor_sup]}, {_,ChSup,supervisor,[ssh_channel_sup]}, {connection,ServerConn,worker,[ssh_connection_handler]}], - supervisor:which_children(SubSysSup), + supervisor:which_children(ConnectionSup), [ChSup,ServerConn]), ?wait_match([{_,PidS,worker,[ssh_server_channel]}], @@ -412,15 +412,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)), @@ -429,7 +429,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]} @@ -442,7 +442,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]}, @@ -457,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]} @@ -471,7 +471,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)),