Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ssh/src/ssh.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@
"erts-14.0",
"kernel-10.3",
"public_key-1.6.1",
"stdlib-6.0","stdlib-5.0",
"stdlib-@OTP-19800@",
"runtime_tools-1.15.1"
]}]}.
7 changes: 6 additions & 1 deletion lib/ssh/src/ssh.erl
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,12 @@ stop_daemon(Address, Port) ->
stop_daemon(Address, Port, ?DEFAULT_PROFILE).


-doc "Stops the listener and all connections started by the listener.".
-doc """
Stops the listener and all connections started by the listener.

If the daemon process does not exist, the call exits the calling process
with reason `noproc`.
""".
-doc(#{since => <<"OTP 21.0">>}).
-spec stop_daemon(any|inet:ip_address(), inet:port_number(), atom()) -> ok.

Expand Down
14 changes: 2 additions & 12 deletions lib/ssh/src/ssh_system_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,7 @@ start_system(Address0, Options) ->

%%%----------------------------------------------------------------
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(Id) ->
supervisor:terminate_child(sup(server), {?MODULE, Id}).

supervisor:stop(SysSup).

%%%----------------------------------------------------------------
stop_listener(SystemSup) when is_pid(SystemSup) ->
Expand All @@ -104,7 +98,7 @@ get_daemon_listen_address(SystemSup) ->
%%% supervisor (callback = this module) for server and non-significant
%%% child of sshc_sup for client
start_connection(Role = client, _, Socket, Options) ->
do_start_connection(Role, sup(client), false, Socket, Options);
do_start_connection(Role, sshc_sup, false, Socket, Options);
start_connection(Role = server, Address=#address{}, Socket, Options) ->
case get_system_sup(Address, Options) of
{ok, SysPid} ->
Expand Down Expand Up @@ -260,10 +254,6 @@ find_system_sup(Address0) ->
[_,_|_] -> {error,ambiguous}
end.

sup(client) -> sshc_sup;
sup(server) -> sshd_sup.


is_socket_server(Options) ->
undefined =/= ?GET_INTERNAL_OPT(connected_socket,Options,undefined).

Expand Down
17 changes: 9 additions & 8 deletions lib/ssh/test/ssh_connection_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1711,11 +1711,10 @@ stop_listener(Config) when is_list(Config) ->
file:make_dir(UserDir),
SysDir = proplists:get_value(data_dir, Config),

{Pid0, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir},
{user_dir, UserDir},
{password, "morot"},
{exec, fun ssh_exec_echo/1}]),

ConnectionRef0 = ssh_test_lib:connect(Host, Port,
[{silently_accept_hosts, true},
{user, "foo"},
Expand Down Expand Up @@ -1744,11 +1743,14 @@ stop_listener(Config) when is_list(Config) ->
ct:fail("Exec Timeout")
end,

%% Same daemon ref (Pid) is expected to be received below as
%% previously started system supervisor is still running and
%% assigned to Port
case ssh_test_lib:daemon(Port, [{system_dir, SysDir},
{user_dir, UserDir},
{password, "potatis"},
{exec, fun ssh_exec_echo/1}]) of
{Pid1, Host, Port} ->
{Pid, Host, Port} ->
ConnectionRef1 =
ssh_test_lib:connect(Host, Port, [{silently_accept_hosts, true},
{user, "foo"},
Expand All @@ -1761,13 +1763,12 @@ stop_listener(Config) when is_list(Config) ->
{password, "morot"},
{user_interaction, true},
{user_dir, UserDir}]),
ssh:close(ConnectionRef0),
ssh:close(ConnectionRef1),
ssh:stop_daemon(Pid0),
ssh:stop_daemon(Pid1);
ok = ssh:close(ConnectionRef0),
ok = ssh:close(ConnectionRef1),
ok = ssh:stop_daemon(Pid);
Error ->
ssh:close(ConnectionRef0),
ssh:stop_daemon(Pid0),
ssh:stop_daemon(Pid),
ct:fail({unexpected, Error})
end.

Expand Down
Loading