aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ranch_acceptor.erl10
-rw-r--r--src/ranch_acceptors_sup.erl20
-rw-r--r--src/ranch_listener_sup.erl2
-rw-r--r--src/ranch_server.erl3
4 files changed, 18 insertions, 17 deletions
diff --git a/src/ranch_acceptor.erl b/src/ranch_acceptor.erl
index 040145b..692277b 100644
--- a/src/ranch_acceptor.erl
+++ b/src/ranch_acceptor.erl
@@ -16,17 +16,17 @@
-module(ranch_acceptor).
%% API.
--export([start_link/7]).
+-export([start_link/6]).
%% Internal.
-export([acceptor/7]).
%% API.
--spec start_link(any(), inet:socket(), module(), module(), any(),
- pid(), pid()) -> {ok, pid()}.
-start_link(Ref, LSocket, Transport, Protocol, Opts,
- ListenerPid, ConnsSup) ->
+-spec start_link(any(), inet:socket(), module(), module(), pid(), pid())
+ -> {ok, pid()}.
+start_link(Ref, LSocket, Transport, Protocol, ListenerPid, ConnsSup) ->
+ {ok, Opts} = ranch_listener:get_protocol_options(ListenerPid),
Pid = spawn_link(?MODULE, acceptor,
[LSocket, Transport, Protocol, Opts, 1, ListenerPid, ConnsSup]),
ok = ranch_server:add_acceptor(Ref, Pid),
diff --git a/src/ranch_acceptors_sup.erl b/src/ranch_acceptors_sup.erl
index 8cdef17..2e45acf 100644
--- a/src/ranch_acceptors_sup.erl
+++ b/src/ranch_acceptors_sup.erl
@@ -17,7 +17,7 @@
-behaviour(supervisor).
%% API.
--export([start_link/8]).
+-export([start_link/7]).
%% supervisor.
-export([init/1]).
@@ -25,22 +25,22 @@
%% API.
-spec start_link(any(), non_neg_integer(), module(), any(),
- module(), any(), pid(), pid()) -> {ok, pid()}.
+ module(), pid(), pid()) -> {ok, pid()}.
start_link(Ref, NbAcceptors, Transport, TransOpts,
- Protocol, ProtoOpts, ListenerPid, ConnsPid) ->
+ Protocol, ListenerPid, ConnsPid) ->
supervisor:start_link(?MODULE, [Ref, NbAcceptors, Transport, TransOpts,
- Protocol, ProtoOpts, ListenerPid, ConnsPid]).
+ Protocol, ListenerPid, ConnsPid]).
%% supervisor.
init([Ref, NbAcceptors, Transport, TransOpts,
- Protocol, ProtoOpts, ListenerPid, ConnsPid]) ->
+ Protocol, ListenerPid, ConnsPid]) ->
{ok, LSocket} = Transport:listen(TransOpts),
{ok, {_, Port}} = Transport:sockname(LSocket),
ranch_listener:set_port(ListenerPid, Port),
- Procs = [{{acceptor, self(), N}, {ranch_acceptor, start_link, [
- Ref, LSocket, Transport, Protocol, ProtoOpts,
- ListenerPid, ConnsPid
- ]}, permanent, brutal_kill, worker, []}
- || N <- lists:seq(1, NbAcceptors)],
+ Procs = [
+ {{acceptor, self(), N}, {ranch_acceptor, start_link, [
+ Ref, LSocket, Transport, Protocol, ListenerPid, ConnsPid
+ ]}, permanent, brutal_kill, worker, []}
+ || N <- lists:seq(1, NbAcceptors)],
{ok, {{one_for_one, 10, 10}, Procs}}.
diff --git a/src/ranch_listener_sup.erl b/src/ranch_listener_sup.erl
index 6adf618..de35758 100644
--- a/src/ranch_listener_sup.erl
+++ b/src/ranch_listener_sup.erl
@@ -39,7 +39,7 @@ start_link(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) ->
{ok, _PoolPid} = supervisor:start_child(SupPid,
{ranch_acceptors_sup, {ranch_acceptors_sup, start_link, [
Ref, NbAcceptors, Transport, TransOpts,
- Protocol, ProtoOpts, ListenerPid, ConnsPid
+ Protocol, ListenerPid, ConnsPid
]}, permanent, 5000, supervisor, [ranch_acceptors_sup]}),
{ok, SupPid}.
diff --git a/src/ranch_server.erl b/src/ranch_server.erl
index 7ded858..16e892d 100644
--- a/src/ranch_server.erl
+++ b/src/ranch_server.erl
@@ -117,8 +117,9 @@ code_change(_OldVsn, State, _Extra) ->
-spec remove_process(key(), reference(), pid(), Monitors)
-> Monitors when Monitors::monitors() .
-remove_process(Key = {listener, _}, MonitorRef, Pid, Monitors) ->
+remove_process(Key = {listener, Ref}, MonitorRef, Pid, Monitors) ->
true = ets:delete(?TAB, Key),
+ true = ets:delete(?TAB, {acceptors, Ref}),
lists:keydelete({MonitorRef, Pid}, 1, Monitors);
remove_process(Key = {acceptors, _}, MonitorRef, Pid, Monitors) ->
Acceptors = ets:lookup_element(?TAB, Key, 2),