aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/sshd_sup.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-03-21 19:50:49 +0100
committerHans Nilsson <[email protected]>2017-04-07 10:23:34 +0200
commit6158cb432092c47e178b4dc1177b46cb8c310ab4 (patch)
tree8d6d5ff1f0f2b70eb7bc1cbe4e5fa5e440e3764e /lib/ssh/src/sshd_sup.erl
parent57d994270d63e7a9ce80eece3c1c3aeca79d3ea4 (diff)
downloadotp-6158cb432092c47e178b4dc1177b46cb8c310ab4.tar.gz
otp-6158cb432092c47e178b4dc1177b46cb8c310ab4.tar.bz2
otp-6158cb432092c47e178b4dc1177b46cb8c310ab4.zip
ssh: Fix supervisors, start daemon and connect code
Remove many internal options and made them as explicit arguments.
Diffstat (limited to 'lib/ssh/src/sshd_sup.erl')
-rw-r--r--lib/ssh/src/sshd_sup.erl55
1 files changed, 21 insertions, 34 deletions
diff --git a/lib/ssh/src/sshd_sup.erl b/lib/ssh/src/sshd_sup.erl
index 791456839d..d4805e9465 100644
--- a/lib/ssh/src/sshd_sup.erl
+++ b/lib/ssh/src/sshd_sup.erl
@@ -29,8 +29,11 @@
-include("ssh.hrl").
--export([start_link/1, start_child/1, stop_child/1,
- stop_child/3, system_name/1]).
+-export([start_link/0,
+ start_child/4,
+ stop_child/1,
+ stop_child/3,
+ system_name/1]).
%% Supervisor callback
-export([init/1]).
@@ -38,27 +41,23 @@
%%%=========================================================================
%%% API
%%%=========================================================================
-start_link(Servers) ->
- supervisor:start_link({local, ?MODULE}, ?MODULE, [Servers]).
+start_link() ->
+ supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-start_child(Options) ->
- Address = ?GET_INTERNAL_OPT(address, Options),
- Port = ?GET_INTERNAL_OPT(port, Options),
- Profile = ?GET_OPT(profile, Options),
+start_child(Address, Port, Profile, Options) ->
+io:format("~p:~p ~p:~p~n",[?MODULE,?LINE,Address, Port]),
case ssh_system_sup:system_supervisor(Address, Port, Profile) of
undefined ->
- Spec = child_spec(Address, Port, Options),
- case supervisor:start_child(?MODULE, Spec) of
- {error, already_present} ->
- Name = id(Address, Port, Profile),
- supervisor:delete_child(?MODULE, Name),
- supervisor:start_child(?MODULE, Spec);
- Reply ->
- Reply
- end;
+io:format("~p:~p undefined~n",[?MODULE,?LINE]),
+ Spec = child_spec(Address, Port, Profile, Options),
+ Reply = supervisor:start_child(?MODULE, Spec),
+io:format("~p:~p Reply=~p~n",[?MODULE,?LINE,Reply]),
+ Reply;
Pid ->
+io:format("~p:~p Pid=~p~n",[?MODULE,?LINE,Pid]),
AccPid = ssh_system_sup:acceptor_supervisor(Pid),
- ssh_acceptor_sup:start_child(AccPid, Options)
+ ssh_acceptor_sup:start_child(AccPid, Address, Port, Profile, Options),
+ {ok,Pid}
end.
stop_child(Name) ->
@@ -75,27 +74,15 @@ system_name(SysSup) ->
%%%=========================================================================
%%% Supervisor callback
%%%=========================================================================
--spec init( [term()] ) -> {ok,{supervisor:sup_flags(),[supervisor:child_spec()]}} | ignore .
-
-init([Servers]) ->
- RestartStrategy = one_for_one,
- MaxR = 10,
- MaxT = 3600,
- Fun = fun(ServerOpts) ->
- Address = ?GET_INTERNAL_OPT(address, ServerOpts),
- Port = ?GET_INTERNAL_OPT(port, ServerOpts),
- child_spec(Address, Port, ServerOpts)
- end,
- Children = lists:map(Fun, Servers),
- {ok, {{RestartStrategy, MaxR, MaxT}, Children}}.
+init(_) ->
+ {ok, {{one_for_one, 10, 3600}, []}}.
%%%=========================================================================
%%% Internal functions
%%%=========================================================================
-child_spec(Address, Port, Options) ->
- Profile = ?GET_OPT(profile, Options),
+child_spec(Address, Port, Profile, Options) ->
Name = id(Address, Port,Profile),
- StartFunc = {ssh_system_sup, start_link, [Options]},
+ StartFunc = {ssh_system_sup, start_link, [Address, Port, Profile, Options]},
Restart = temporary,
Shutdown = infinity,
Modules = [ssh_system_sup],