From 43d14b52cd07dfd1121bbe6727a96dfd32304e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 10 Aug 2011 20:28:30 +0200 Subject: Give the ListenerPid to the protocol on startup Also sends a message 'shoot' that can be received by the protocol to make sure Cowboy has had enough time to fully initialize the socket. This message should be received before any socket-related operations are performed. WebSocket request connections are now moved from the pool 'default' to the pool 'websocket', meaning we can have a lot of running WebSockets despite having a low 'max_connections' setting. --- src/cowboy_acceptor.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/cowboy_acceptor.erl') diff --git a/src/cowboy_acceptor.erl b/src/cowboy_acceptor.erl index be63cef..f2b603e 100644 --- a/src/cowboy_acceptor.erl +++ b/src/cowboy_acceptor.erl @@ -36,10 +36,11 @@ acceptor(LSocket, Transport, Protocol, Opts, MaxConns, ListenerPid, ReqsSup) -> case Transport:accept(LSocket, 2000) of {ok, CSocket} -> {ok, Pid} = supervisor:start_child(ReqsSup, - [CSocket, Transport, Protocol, Opts]), + [ListenerPid, CSocket, Transport, Protocol, Opts]), Transport:controlling_process(CSocket, Pid), {ok, NbConns} = cowboy_listener:add_connection(ListenerPid, default, Pid), + Pid ! shoot, limit_reqs(ListenerPid, NbConns, MaxConns); {error, timeout} -> ignore; -- cgit v1.2.3