aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFred Hebert <[email protected]>2013-01-11 10:31:00 -0500
committerFred Hebert <[email protected]>2013-01-15 11:45:50 -0500
commit662d94a531178af005f06b0bfb4a8660b0fa023f (patch)
tree52bf6e87f4d6b6be23f6170212edc96c0a96704a /test
parent9fd9294a13375a56c42b4b77225bbe317ecf0b4d (diff)
downloadranch-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 'test')
-rw-r--r--test/acceptor_SUITE.erl21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl
index f5db464..8827ec8 100644
--- a/test/acceptor_SUITE.erl
+++ b/test/acceptor_SUITE.erl
@@ -40,6 +40,7 @@
-export([tcp_max_connections/1]).
-export([tcp_max_connections_and_beyond/1]).
-export([tcp_set_max_connections/1]).
+-export([tcp_infinity_max_connections/1]).
-export([tcp_upgrade/1]).
%% supervisor.
@@ -58,6 +59,7 @@ groups() ->
tcp_active_echo,
tcp_echo,
tcp_max_connections,
+ tcp_infinity_max_connections,
tcp_max_connections_and_beyond,
tcp_set_max_connections,
tcp_upgrade
@@ -275,6 +277,25 @@ tcp_set_max_connections(_) ->
10 = receive_loop(connected, 1000),
20 = ranch:get_max_connections(tcp_set_max_connections).
+tcp_infinity_max_connections(_) ->
+ {ok, _} = ranch:start_listener(tcp_infinity_max_connections, 1,
+ ranch_tcp, [{port, 0}, {max_connections, 10}],
+ notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ Port = ranch:get_port(tcp_infinity_max_connections),
+ %% @todo We'll probably want a more direct interface to count_connections.
+ ListenerPid = ranch_server:lookup_listener(tcp_infinity_max_connections),
+ ok = connect_loop(Port, 20, 0),
+ 10 = ranch_server:count_connections(ListenerPid),
+ 10 = receive_loop(connected, 1000),
+ 10 = ranch:get_max_connections(tcp_infinity_max_connections),
+ ranch:set_max_connections(tcp_infinity_max_connections, infinity),
+ 0 = ranch_server:count_connections(ListenerPid),
+ infinity = ranch:get_max_connections(tcp_infinity_max_connections),
+ ranch:set_max_connections(tcp_infinity_max_connections, 10),
+ 0 = ranch_server:count_connections(ListenerPid),
+ 10 = receive_loop(connected, 1000),
+ 10 = ranch_server:count_connections(ListenerPid). % count could be off
+
tcp_upgrade(_) ->
receive after 20000 -> ok end,
{ok, _} = ranch:start_listener(tcp_upgrade, 1,