diff options
author | juhlig <[email protected]> | 2019-05-08 15:05:27 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-05-08 16:38:47 +0200 |
commit | d59eef5c737d0b08eb8c16c5316300e863bc935c (patch) | |
tree | be6ab3327717f847677484edf027af9e21266045 /src/ranch_conns_sup.erl | |
parent | aa64151149e947145728a1f1339c689f1100720e (diff) | |
download | ranch-d59eef5c737d0b08eb8c16c5316300e863bc935c.tar.gz ranch-d59eef5c737d0b08eb8c16c5316300e863bc935c.tar.bz2 ranch-d59eef5c737d0b08eb8c16c5316300e863bc935c.zip |
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.
Diffstat (limited to 'src/ranch_conns_sup.erl')
-rw-r--r-- | src/ranch_conns_sup.erl | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/ranch_conns_sup.erl b/src/ranch_conns_sup.erl index 0ff12c6..171565e 100644 --- a/src/ranch_conns_sup.erl +++ b/src/ranch_conns_sup.erl @@ -34,7 +34,6 @@ -record(state, { parent = undefined :: pid(), ref :: ranch:ref(), - acceptor_id :: non_neg_integer(), conn_type :: conn_type(), shutdown :: shutdown(), transport = undefined :: module(), @@ -47,10 +46,10 @@ %% API. --spec start_link(ranch:ref(), non_neg_integer(), module(), module()) -> {ok, pid()}. -start_link(Ref, AcceptorId, Transport, Protocol) -> +-spec start_link(ranch:ref(), pos_integer(), module(), module()) -> {ok, pid()}. +start_link(Ref, Id, Transport, Protocol) -> proc_lib:start_link(?MODULE, init, - [self(), Ref, AcceptorId, Transport, Protocol]). + [self(), Ref, Id, Transport, Protocol]). %% We can safely assume we are on the same node as the supervisor. %% @@ -100,10 +99,10 @@ active_connections(SupPid) -> %% Supervisor internals. --spec init(pid(), ranch:ref(), non_neg_integer(), module(), module()) -> no_return(). -init(Parent, Ref, AcceptorId, Transport, Protocol) -> +-spec init(pid(), ranch:ref(), pos_integer(), module(), module()) -> no_return(). +init(Parent, Ref, Id, Transport, Protocol) -> process_flag(trap_exit, true), - ok = ranch_server:set_connections_sup(Ref, AcceptorId, self()), + ok = ranch_server:set_connections_sup(Ref, Id, self()), MaxConns = ranch_server:get_max_connections(Ref), TransOpts = ranch_server:get_transport_options(Ref), ConnType = maps:get(connection_type, TransOpts, worker), @@ -112,7 +111,7 @@ init(Parent, Ref, AcceptorId, Transport, Protocol) -> Logger = maps:get(logger, TransOpts, error_logger), ProtoOpts = ranch_server:get_protocol_options(Ref), ok = proc_lib:init_ack(Parent, {ok, self()}), - loop(#state{parent=Parent, ref=Ref, acceptor_id=AcceptorId, conn_type=ConnType, + loop(#state{parent=Parent, ref=Ref, conn_type=ConnType, shutdown=Shutdown, transport=Transport, protocol=Protocol, opts=ProtoOpts, handshake_timeout=HandshakeTimeout, max_conns=MaxConns, logger=Logger}, 0, 0, []). |