diff options
author | Fred Hebert <[email protected]> | 2013-01-11 10:31:00 -0500 |
---|---|---|
committer | Fred Hebert <[email protected]> | 2013-01-15 11:45:50 -0500 |
commit | 662d94a531178af005f06b0bfb4a8660b0fa023f (patch) | |
tree | 52bf6e87f4d6b6be23f6170212edc96c0a96704a /src/ranch_acceptor.erl | |
parent | 9fd9294a13375a56c42b4b77225bbe317ecf0b4d (diff) | |
download | ranch-662d94a531178af005f06b0bfb4a8660b0fa023f.tar.gz ranch-662d94a531178af005f06b0bfb4a8660b0fa023f.tar.bz2 ranch-662d94a531178af005f06b0bfb4a8660b0fa023f.zip |
Ignore tracking of requests when MaxConn = infinity
There is no need to contact the server and track requests unless being
asked to do so by the user. It's going to be faster and more efficient
to not track anything when being told tracking doesn't matter.
Whenever the max connections is set to infinity, the connections
counting key is not created, or is deleted if it existed already.
When using a numeric value, the connection count is created or
maintained if it existed already.
Moreover, trying to reduce a listener's counter while the max connection
number is set to `infinity` will return 0 and avoid all counting
operations as they are meaningless.
Diffstat (limited to 'src/ranch_acceptor.erl')
-rw-r--r-- | src/ranch_acceptor.erl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ranch_acceptor.erl b/src/ranch_acceptor.erl index aef98d7..63d24c8 100644 --- a/src/ranch_acceptor.erl +++ b/src/ranch_acceptor.erl @@ -56,8 +56,13 @@ loop(LSocket, Transport, Protocol, MaxConns, Opts, ListenerPid, ConnsSup) -> [ListenerPid, CSocket, Transport, Protocol, Opts]), Transport:controlling_process(CSocket, ConnPid), ConnPid ! {shoot, ListenerPid}, - NbConns = ranch_listener:add_connection(ListenerPid, ConnPid), - {ok, MaxConns2} = maybe_wait(ListenerPid, MaxConns, NbConns), + {ok, MaxConns2} = case MaxConns of + infinity -> + {ok, infinity}; + _ -> + NbConns = ranch_listener:add_connection(ListenerPid, ConnPid), + maybe_wait(ListenerPid, MaxConns, NbConns) + end, ?MODULE:init(LSocket, Transport, Protocol, MaxConns2, Opts, ListenerPid, ConnsSup); %% Upgrade the max number of connections allowed concurrently. |