From d59eef5c737d0b08eb8c16c5316300e863bc935c Mon Sep 17 00:00:00 2001 From: juhlig Date: Wed, 8 May 2019 15:05:27 +0200 Subject: Add the num_conns_sups option This new option allows configuring the number of connection supervisors. The old behavior can be obtained by setting this value to 1. A value larger than num_acceptors will result in some connection supervisors not being used as the acceptors currently only use one connection supervisor. --- src/ranch_conns_sup_sup.erl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/ranch_conns_sup_sup.erl') diff --git a/src/ranch_conns_sup_sup.erl b/src/ranch_conns_sup_sup.erl index 423c5db..142b9de 100644 --- a/src/ranch_conns_sup_sup.erl +++ b/src/ranch_conns_sup_sup.erl @@ -19,16 +19,17 @@ -export([start_link/4]). -export([init/1]). -start_link(Ref, NumAcceptors, Transport, Protocol) -> +-spec start_link(ranch:ref(), pos_integer(), ranch:opts(), module()) -> {ok, pid()}. +start_link(Ref, NumConnsSups, Transport, Protocol) -> ok = ranch_server:cleanup_connections_sups(Ref), supervisor:start_link(?MODULE, { - Ref, NumAcceptors, Transport, Protocol + Ref, NumConnsSups, Transport, Protocol }). -init({Ref, NumAcceptors, Transport, Protocol}) -> +init({Ref, NumConnsSups, Transport, Protocol}) -> ChildSpecs = [ {{ranch_conns_sup, N}, {ranch_conns_sup, start_link, [Ref, N, Transport, Protocol]}, permanent, infinity, supervisor, [ranch_conns_sup]} - || N <- lists:seq(1, NumAcceptors)], + || N <- lists:seq(1, NumConnsSups)], {ok, {{one_for_one, 1, 5}, ChildSpecs}}. -- cgit v1.2.3