diff options
Diffstat (limited to 'src/ranch_conns_sup_sup.erl')
-rw-r--r-- | src/ranch_conns_sup_sup.erl | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/ranch_conns_sup_sup.erl b/src/ranch_conns_sup_sup.erl index 4b1dd47..61ace8e 100644 --- a/src/ranch_conns_sup_sup.erl +++ b/src/ranch_conns_sup_sup.erl @@ -19,19 +19,22 @@ -export([start_link/4]). -export([init/1]). --spec start_link(ranch:ref(), pos_integer(), ranch:opts(), module()) -> {ok, pid()}. -start_link(Ref, NumConnsSups, Transport, Protocol) -> +-spec start_link(ranch:ref(), module(), module(), module()) -> {ok, pid()}. +start_link(Ref, Transport, Protocol, Logger) -> ok = ranch_server:cleanup_connections_sups(Ref), supervisor:start_link(?MODULE, { - Ref, NumConnsSups, Transport, Protocol + Ref, Transport, Protocol, Logger }). --spec init({ranch:ref(), pos_integer(), module(), module()}) +-spec init({ranch:ref(), module(), module(), module()}) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}. -init({Ref, NumConnsSups, Transport, Protocol}) -> +init({Ref, Transport, Protocol, Logger}) -> + TransOpts = ranch_server:get_transport_options(Ref), + NumAcceptors = maps:get(num_acceptors, TransOpts, 10), + NumConnsSups = maps:get(num_conns_sups, TransOpts, NumAcceptors), ChildSpecs = [#{ id => {ranch_conns_sup, N}, - start => {ranch_conns_sup, start_link, [Ref, N, Transport, Protocol]}, + start => {ranch_conns_sup, start_link, [Ref, N, Transport, TransOpts, Protocol, Logger]}, type => supervisor } || N <- lists:seq(1, NumConnsSups)], {ok, {#{intensity => 1 + ceil(math:log2(NumConnsSups))}, ChildSpecs}}. |