From 6b354c1124035c54b6648665aafbe7197b34bd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 6 Aug 2012 13:39:28 +0200 Subject: Make accept asynchronous Ranch now accepts connection asynchronously through a separate process. The accept process is linked to the acceptor, calls accept and does nothing else but send the socket back to the acceptor. This allows us to receive messages in the acceptor to handle upgrades instead of polling. This will also allow us later to make acceptors system processes. Remove support for connection pools in favor of a simpler max_connections setting. Connections can be removed from the count, allowing us to have as many long-lived connections as we want while still limiting the number of short-lived ones. Add max_connections, max_connections with long-lived connections, and upgrade tests. --- src/ranch_listener_sup.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ranch_listener_sup.erl') diff --git a/src/ranch_listener_sup.erl b/src/ranch_listener_sup.erl index de35758..c8ba12d 100644 --- a/src/ranch_listener_sup.erl +++ b/src/ranch_listener_sup.erl @@ -30,7 +30,8 @@ start_link(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) -> MaxConns = proplists:get_value(max_connections, TransOpts, 1024), {ok, SupPid} = supervisor:start_link(?MODULE, []), {ok, ListenerPid} = supervisor:start_child(SupPid, - {ranch_listener, {ranch_listener, start_link, [MaxConns, ProtoOpts]}, + {ranch_listener, {ranch_listener, start_link, + [Ref, MaxConns, ProtoOpts]}, permanent, 5000, worker, [ranch_listener]}), ok = ranch_server:insert_listener(Ref, ListenerPid), {ok, ConnsPid} = supervisor:start_child(SupPid, -- cgit v1.2.3