Skip to content

Commit

Permalink
Merge branch 'kuba/ssh/refactor_server_supervision'
Browse files Browse the repository at this point in the history
* kuba/ssh/refactor_server_supervision:
  ssh: refactor ssh_system_sup
  • Loading branch information
u3s committed Dec 17, 2024
2 parents 23567fd + 43bbe46 commit e7f8ffd
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/ssh/src/ssh_system_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

-include("ssh.hrl").

-export([start_link/3,
-export([start_link/2,
stop_listener/1,
stop_system/1,
start_system/2,
Expand Down Expand Up @@ -62,7 +62,7 @@ start_system(Address0, Options) ->
{error,not_found} ->
supervisor:start_child(sshd_sup,
#{id => {?MODULE,Address0},
start => {?MODULE, start_link, [server, Address0, Options]},
start => {?MODULE, start_link, [Address0, Options]},
restart => temporary,
type => supervisor
})
Expand Down Expand Up @@ -147,8 +147,8 @@ do_start_connection(Role, SupPid, Significant, Socket, Options0) ->
end.

%%%----------------------------------------------------------------
start_link(Role, Address, Options) ->
supervisor:start_link(?MODULE, [Role, Address, Options]).
start_link(Address, Options) ->
supervisor:start_link(?MODULE, [Address, Options]).

%%%----------------------------------------------------------------
addresses(#address{address=Address, port=Port, profile=Profile}) ->
Expand Down Expand Up @@ -189,16 +189,16 @@ restart_acceptor(SysPid, Options0) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
init([Role, Address, Options]) ->
ssh_lib:set_label(Role, system_sup),
init([Address, Options]) ->
ssh_lib:set_label(server, system_sup),
SupFlags = #{strategy => one_for_one,
auto_shutdown => all_significant,
intensity => 0,
period => 3600
},
ChildSpecs =
case {Role, is_socket_server(Options)} of
{server, false} ->
case is_socket_server(Options) of
false ->
[acceptor_sup_child_spec(_SysSup=self(), Address, Options)];
_ ->
[]
Expand Down Expand Up @@ -274,8 +274,6 @@ start_acceptor(SysPid, Address, Options) ->
case supervisor:start_child(SysPid, ChildSpec) of
{ok,_ChildPid} ->
{ok,SysPid}; % sic!
{ok,_ChildPid,_Info} ->
{ok,SysPid}; % sic!
{error,Error} ->
{error,Error}
end
Expand Down

0 comments on commit e7f8ffd

Please sign in to comment.