aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_acceptor.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-04-02 20:27:16 +0200
committerLoïc Hoguin <[email protected]>2011-04-02 20:27:16 +0200
commite4da6956fceea1af8e2cdf9fece0e014576ab43c (patch)
treec182e61fd7f7500a40bd5346b582e50afc910431 /src/cowboy_acceptor.erl
parente6e5b1767fe379c3fb9a9c46f2ec2b05bf485ce8 (diff)
downloadcowboy-e4da6956fceea1af8e2cdf9fece0e014576ab43c.tar.gz
cowboy-e4da6956fceea1af8e2cdf9fece0e014576ab43c.tar.bz2
cowboy-e4da6956fceea1af8e2cdf9fece0e014576ab43c.zip
Anonymize and improve the cowboy supervision tree.
* Cowboy isn't an OTP application anymore; just a supervisor. * All processes started by Cowboy are now anonymous. * All processes related to a listener are now part of its supervision tree.
Diffstat (limited to 'src/cowboy_acceptor.erl')
-rw-r--r--src/cowboy_acceptor.erl19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/cowboy_acceptor.erl b/src/cowboy_acceptor.erl
index d4d7f5c..0dbd9b0 100644
--- a/src/cowboy_acceptor.erl
+++ b/src/cowboy_acceptor.erl
@@ -13,27 +13,28 @@
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-module(cowboy_acceptor).
--export([start_link/4]). %% API.
--export([acceptor/4]). %% Internal.
+-export([start_link/5]). %% API.
+-export([acceptor/5]). %% Internal.
-include("include/types.hrl").
%% API.
-spec start_link(LSocket::socket(), Transport::module(),
- Protocol::module(), Opts::term()) -> {ok, Pid::pid()}.
-start_link(LSocket, Transport, Protocol, Opts) ->
- Pid = spawn_link(?MODULE, acceptor, [LSocket, Transport, Protocol, Opts]),
+ Protocol::module(), Opts::term(), ReqsSup::pid()) -> {ok, Pid::pid()}.
+start_link(LSocket, Transport, Protocol, Opts, ReqsSup) ->
+ Pid = spawn_link(?MODULE, acceptor,
+ [LSocket, Transport, Protocol, Opts, ReqsSup]),
{ok, Pid}.
%% Internal.
-spec acceptor(LSocket::socket(), Transport::module(),
- Protocol::module(), Opts::term()) -> no_return().
-acceptor(LSocket, Transport, Protocol, Opts) ->
+ Protocol::module(), Opts::term(), ReqsSup::pid()) -> no_return().
+acceptor(LSocket, Transport, Protocol, Opts, ReqsSup) ->
case Transport:accept(LSocket) of
{ok, CSocket} ->
- {ok, Pid} = supervisor:start_child(cowboy_protocols_sup,
+ {ok, Pid} = supervisor:start_child(ReqsSup,
[CSocket, Transport, Protocol, Opts]),
Transport:controlling_process(CSocket, Pid);
{error, _Reason} ->
@@ -41,4 +42,4 @@ acceptor(LSocket, Transport, Protocol, Opts) ->
%% we may want to try and listen again on the port?
ignore
end,
- ?MODULE:acceptor(LSocket, Transport, Protocol, Opts).
+ ?MODULE:acceptor(LSocket, Transport, Protocol, Opts, ReqsSup).