aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cowboy_acceptors_sup.erl9
-rw-r--r--src/cowboy_listener_sup.erl29
2 files changed, 13 insertions, 25 deletions
diff --git a/src/cowboy_acceptors_sup.erl b/src/cowboy_acceptors_sup.erl
index c5e7db4..66ac4a9 100644
--- a/src/cowboy_acceptors_sup.erl
+++ b/src/cowboy_acceptors_sup.erl
@@ -25,14 +25,15 @@
-spec start_link(NbAcceptors::non_neg_integer(), Transport::module(),
TransOpts::term(), Protocol::module(), ProtoOpts::term(), ReqsPid::pid())
-> {ok, Pid::pid()}.
-start_link(LSocket, NbAcceptors, Transport, Protocol, ProtoOpts, ReqsPid) ->
- supervisor:start_link(?MODULE, [LSocket, NbAcceptors,
- Transport, Protocol, ProtoOpts, ReqsPid]).
+start_link(NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ReqsPid) ->
+ supervisor:start_link(?MODULE, [NbAcceptors,
+ Transport, TransOpts, Protocol, ProtoOpts, ReqsPid]).
%% supervisor.
-spec init(list(term())) -> term(). %% @todo These specs should be improved.
-init([LSocket, NbAcceptors, Transport, Protocol, ProtoOpts, ReqsPid]) ->
+init([NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ReqsPid]) ->
+ {ok, LSocket} = Transport:listen(TransOpts),
Procs = [{{acceptor, self(), N}, {cowboy_acceptor, start_link, [
LSocket, Transport, Protocol, ProtoOpts, ReqsPid
]}, permanent, brutal_kill, worker, dynamic}
diff --git a/src/cowboy_listener_sup.erl b/src/cowboy_listener_sup.erl
index 85b17ef..e77c237 100644
--- a/src/cowboy_listener_sup.erl
+++ b/src/cowboy_listener_sup.erl
@@ -24,32 +24,19 @@
TransOpts::term(), Protocol::module(), ProtoOpts::term())
-> {ok, Pid::pid()}.
start_link(NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) ->
- case Transport:listen(TransOpts) of
- {ok, LSocket} ->
- start_sup(LSocket, NbAcceptors, Transport, Protocol, ProtoOpts);
- {error, Reason} ->
- {error, Reason}
- end.
-
-%% supervisor.
-
-%% @todo These specs should be improved.
--spec init([]) -> term().
-init([]) ->
- {ok, {{one_for_one, 0, 1}, []}}.
-
-%% Internal.
-
--spec start_sup(NbAcceptors::non_neg_integer(), Transport::module(),
- TransOpts::term(), Protocol::module(), ProtoOpts::term())
- -> {ok, Pid::pid()}.
-start_sup(LSocket, NbAcceptors, Transport, Protocol, ProtoOpts) ->
{ok, SupPid} = supervisor:start_link(?MODULE, []),
{ok, ReqsPid} = supervisor:start_child(SupPid,
{cowboy_requests_sup, {cowboy_requests_sup, start_link, []},
permanent, 5000, supervisor, [cowboy_requests_sup]}),
{ok, _PoolPid} = supervisor:start_child(SupPid,
{cowboy_acceptors_sup, {cowboy_acceptors_sup, start_link, [
- LSocket, NbAcceptors, Transport, Protocol, ProtoOpts, ReqsPid
+ NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts, ReqsPid
]}, permanent, 5000, supervisor, [cowboy_acceptors_sup]}),
{ok, SupPid}.
+
+%% supervisor.
+
+%% @todo These specs should be improved.
+-spec init([]) -> term().
+init([]) ->
+ {ok, {{one_for_one, 0, 1}, []}}.