aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ranch_conns_sup.erl24
-rw-r--r--src/ranch_listener_sup.erl9
-rw-r--r--src/ranch_server.erl8
3 files changed, 20 insertions, 21 deletions
diff --git a/src/ranch_conns_sup.erl b/src/ranch_conns_sup.erl
index 6a2336f..812a6c3 100644
--- a/src/ranch_conns_sup.erl
+++ b/src/ranch_conns_sup.erl
@@ -18,12 +18,12 @@
-module(ranch_conns_sup).
%% API.
--export([start_link/6]).
+-export([start_link/3]).
-export([start_protocol/2]).
-export([active_connections/1]).
%% Supervisor internals.
--export([init/7]).
+-export([init/4]).
-export([system_continue/3]).
-export([system_terminate/4]).
-export([system_code_change/4]).
@@ -45,11 +45,10 @@
%% API.
--spec start_link(ranch:ref(), conn_type(), shutdown(), module(),
- timeout(), module()) -> {ok, pid()}.
-start_link(Ref, ConnType, Shutdown, Transport, AckTimeout, Protocol) ->
+-spec start_link(ranch:ref(), module(), module()) -> {ok, pid()}.
+start_link(Ref, Transport, Protocol) ->
proc_lib:start_link(?MODULE, init,
- [self(), Ref, ConnType, Shutdown, Transport, AckTimeout, Protocol]).
+ [self(), Ref, Transport, Protocol]).
%% We can safely assume we are on the same node as the supervisor.
%%
@@ -94,17 +93,20 @@ active_connections(SupPid) ->
%% Supervisor internals.
--spec init(pid(), ranch:ref(), conn_type(), shutdown(),
- module(), timeout(), module()) -> no_return().
-init(Parent, Ref, ConnType, Shutdown, Transport, AckTimeout, Protocol) ->
+-spec init(pid(), ranch:ref(), module(), module()) -> no_return().
+init(Parent, Ref, Transport, Protocol) ->
process_flag(trap_exit, true),
ok = ranch_server:set_connections_sup(Ref, self()),
MaxConns = ranch_server:get_max_connections(Ref),
- Opts = ranch_server:get_protocol_options(Ref),
+ TransOpts = ranch_server:get_transport_options(Ref),
+ ConnType = proplists:get_value(connection_type, TransOpts, worker),
+ Shutdown = proplists:get_value(shutdown, TransOpts, 5000),
+ AckTimeout = proplists:get_value(ack_timeout, TransOpts, 5000),
+ ProtoOpts = ranch_server:get_protocol_options(Ref),
ok = proc_lib:init_ack(Parent, {ok, self()}),
loop(#state{parent=Parent, ref=Ref, conn_type=ConnType,
shutdown=Shutdown, transport=Transport, protocol=Protocol,
- opts=Opts, ack_timeout=AckTimeout, max_conns=MaxConns}, 0, 0, []).
+ opts=ProtoOpts, ack_timeout=AckTimeout, max_conns=MaxConns}, 0, 0, []).
loop(State=#state{parent=Parent, ref=Ref, conn_type=ConnType,
transport=Transport, protocol=Protocol, opts=Opts,
diff --git a/src/ranch_listener_sup.erl b/src/ranch_listener_sup.erl
index 502df44..bd4ccc5 100644
--- a/src/ranch_listener_sup.erl
+++ b/src/ranch_listener_sup.erl
@@ -25,17 +25,14 @@ start_link(Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts) ->
ranch_server:set_new_listener_opts(Ref, MaxConns, TransOpts, ProtoOpts,
[Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts]),
supervisor:start_link(?MODULE, {
- Ref, NumAcceptors, Transport, TransOpts, Protocol
+ Ref, NumAcceptors, Transport, Protocol
}).
-init({Ref, NumAcceptors, Transport, TransOpts, Protocol}) ->
+init({Ref, NumAcceptors, Transport, Protocol}) ->
ok = ranch_server:set_listener_sup(Ref, self()),
- AckTimeout = proplists:get_value(ack_timeout, TransOpts, 5000),
- ConnType = proplists:get_value(connection_type, TransOpts, worker),
- Shutdown = proplists:get_value(shutdown, TransOpts, 5000),
ChildSpecs = [
{ranch_conns_sup, {ranch_conns_sup, start_link,
- [Ref, ConnType, Shutdown, Transport, AckTimeout, Protocol]},
+ [Ref, Transport, Protocol]},
permanent, infinity, supervisor, [ranch_conns_sup]},
{ranch_acceptors_sup, {ranch_acceptors_sup, start_link,
[Ref, NumAcceptors, Transport]},
diff --git a/src/ranch_server.erl b/src/ranch_server.erl
index 80f82d6..015c9f9 100644
--- a/src/ranch_server.erl
+++ b/src/ranch_server.erl
@@ -156,10 +156,10 @@ init([]) ->
{ok, #state{monitors=ConnMonitors++ListenerMonitors}}.
handle_call({set_new_listener_opts, Ref, MaxConns, TransOpts, ProtoOpts, StartArgs}, _, State) ->
- ets:insert(?TAB, {{max_conns, Ref}, MaxConns}),
- ets:insert(?TAB, {{trans_opts, Ref}, TransOpts}),
- ets:insert(?TAB, {{proto_opts, Ref}, ProtoOpts}),
- ets:insert(?TAB, {{listener_start_args, Ref}, StartArgs}),
+ ets:insert_new(?TAB, {{max_conns, Ref}, MaxConns}),
+ ets:insert_new(?TAB, {{trans_opts, Ref}, TransOpts}),
+ ets:insert_new(?TAB, {{proto_opts, Ref}, ProtoOpts}),
+ ets:insert_new(?TAB, {{listener_start_args, Ref}, StartArgs}),
{reply, ok, State};
handle_call({set_connections_sup, Ref, Pid}, _,
State=#state{monitors=Monitors}) ->