aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch_acceptors_sup.erl
diff options
context:
space:
mode:
authorAndrew Majorov <[email protected]>2012-11-01 16:50:47 +0400
committerAndrew Majorov <[email protected]>2012-12-21 00:05:12 +0400
commit8dad1451dd6e41f30741ac7554da238aa63c163a (patch)
tree0be82b920136d309b0ca4fafb17d490ab048ae24 /src/ranch_acceptors_sup.erl
parent7f4261d1d83dde90be93d3615693b44969f6b446 (diff)
downloadranch-8dad1451dd6e41f30741ac7554da238aa63c163a.tar.gz
ranch-8dad1451dd6e41f30741ac7554da238aa63c163a.tar.bz2
ranch-8dad1451dd6e41f30741ac7554da238aa63c163a.zip
Make listener supervisor failures less painful
Two general issues were addressed. The first one is the issue with statically defined pids passed into childspecs. This issue prevents regular supervisor' children restarts in the case of someone's failure. The second one is the not quite appropriate restart strategy. Changed to rest_for_one which in pair with previous fixes assures that live connections will not die in the case of partial failure. Among possible failures are listening socket shutdown or frequent accept errors.
Diffstat (limited to 'src/ranch_acceptors_sup.erl')
-rw-r--r--src/ranch_acceptors_sup.erl14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/ranch_acceptors_sup.erl b/src/ranch_acceptors_sup.erl
index 1d9503c..f1908a6 100644
--- a/src/ranch_acceptors_sup.erl
+++ b/src/ranch_acceptors_sup.erl
@@ -17,7 +17,7 @@
-behaviour(supervisor).
%% API.
--export([start_link/7]).
+-export([start_link/5]).
%% supervisor.
-export([init/1]).
@@ -25,16 +25,16 @@
%% API.
-spec start_link(any(), non_neg_integer(), module(), any(),
- module(), pid(), pid()) -> {ok, pid()}.
-start_link(Ref, NbAcceptors, Transport, TransOpts,
- Protocol, ListenerPid, ConnsPid) ->
+ module()) -> {ok, pid()}.
+start_link(Ref, NbAcceptors, Transport, TransOpts, Protocol) ->
supervisor:start_link(?MODULE, [Ref, NbAcceptors, Transport, TransOpts,
- Protocol, ListenerPid, ConnsPid]).
+ Protocol]).
%% supervisor.
-init([Ref, NbAcceptors, Transport, TransOpts,
- Protocol, ListenerPid, ConnsPid]) ->
+init([Ref, NbAcceptors, Transport, TransOpts, Protocol]) ->
+ ListenerPid = ranch_server:lookup_listener(Ref),
+ ConnsPid = ranch_server:lookup_connections_sup(Ref),
LSocket = case proplists:get_value(socket, TransOpts) of
undefined ->
{ok, Socket} = Transport:listen(TransOpts),