aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2013-04-02 14:03:10 +0200
committerLoïc Hoguin <[email protected]>2013-04-02 14:03:10 +0200
commit0343f96bb9d2d7b8247a8a183620ccef8a79c26b (patch)
treea69a72f8c3f9a4280a6d814b032bed545fcca17a
parent109c63d0e76ca6248863932c7a9957f8093cfaf2 (diff)
parent773ce4fdf3f3765f25a91f9bcc61f86be228270a (diff)
downloadranch-0343f96bb9d2d7b8247a8a183620ccef8a79c26b.tar.gz
ranch-0343f96bb9d2d7b8247a8a183620ccef8a79c26b.tar.bz2
ranch-0343f96bb9d2d7b8247a8a183620ccef8a79c26b.zip
Merge branch 'clean-set-max-conns-test' of git://github.com/fishcakez/ranch
-rw-r--r--test/acceptor_SUITE.erl29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl
index db9d4ff..02a5d79 100644
--- a/test/acceptor_SUITE.erl
+++ b/test/acceptor_SUITE.erl
@@ -41,6 +41,7 @@
-export([tcp_max_connections_and_beyond/1]).
-export([tcp_set_max_connections/1]).
-export([tcp_infinity_max_connections/1]).
+-export([tcp_clean_set_max_connections/1]).
-export([tcp_upgrade/1]).
%% supervisor.
@@ -62,6 +63,7 @@ groups() ->
tcp_infinity_max_connections,
tcp_max_connections_and_beyond,
tcp_set_max_connections,
+ tcp_clean_set_max_connections,
tcp_upgrade
]}, {ssl, [
ssl_accept_error,
@@ -321,6 +323,33 @@ tcp_infinity_max_connections(_) ->
10 = receive_loop(connected, 1000),
ranch:stop_listener(Name).
+tcp_clean_set_max_connections(_) ->
+ %% This is a regression test to check that setting max connections does not
+ %% cause any processes to crash.
+ Name = tcp_clean_set_max_connections,
+ {ok, ListSupPid} = ranch:start_listener(Name, 4, ranch_tcp,
+ [{port, 0}, {max_connections, 4}],
+ notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ Children = supervisor:which_children(ListSupPid),
+ {_, AccSupPid, _, _} = lists:keyfind(ranch_acceptors_sup, 1, Children),
+ 1 = erlang:trace(ListSupPid, true, [procs]),
+ 1 = erlang:trace(AccSupPid, true, [procs]),
+ Port = ranch:get_port(tcp_clean_set_max_connections),
+ N = 20,
+ ok = connect_loop(Port, N*5, 0),
+ %% Randomly set max connections.
+ [spawn(ranch, set_max_connections, [tcp_clean_set_max_connections, Max]) ||
+ Max <- lists:flatten(lists:duplicate(N, [6, 4, 8, infinity]))],
+ receive
+ {trace, _, spawn, _, _} ->
+ error(dirty_set_max_connections)
+ after
+ 2000 -> ok
+ end,
+ _ = erlang:trace(all, false, [all]),
+ ok = clean_traces(),
+ ranch:stop_listener(Name).
+
tcp_upgrade(_) ->
Name = tcp_upgrade,
{ok, _} = ranch:start_listener(Name, 1,