From eabb029895c8345ccedc41ed28a023d0e75c7e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 6 Aug 2012 14:23:16 +0200 Subject: Check the accept/2 return value for errors Distinguish the errors from transport_accept and ssl_accept in ranch_ssl. {error, closed} for the first one means the listening socket got closed; for the second one it means the connection socket was. Ignore all errors except when the listening socket got closed, where we want to crash to allow opening the socket again. --- test/acceptor_SUITE.erl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/acceptor_SUITE.erl') diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl index 389f375..1c0931b 100644 --- a/test/acceptor_SUITE.erl +++ b/test/acceptor_SUITE.erl @@ -25,6 +25,7 @@ -export([end_per_group/2]). %% ssl. +-export([ssl_accept_error/1]). -export([ssl_echo/1]). %% tcp. @@ -45,6 +46,7 @@ groups() -> tcp_max_connections_and_beyond, tcp_upgrade ]}, {ssl, [ + ssl_accept_error, ssl_echo ]}]. @@ -74,6 +76,21 @@ end_per_group(_, _) -> %% ssl. +ssl_accept_error(Config) -> + {ok, _} = ranch:start_listener(ssl_accept_error, 1, + ranch_ssl, [{port, 0}, + {certfile, ?config(data_dir, Config) ++ "cert.pem"}], + echo_protocol, []), + Port = ranch:get_port(ssl_accept_error), + [AcceptorPid] = ets:lookup_element(ranch_server, + {acceptors, ssl_accept_error}, 2), + true = is_process_alive(AcceptorPid), + {ok, Socket} = gen_tcp:connect("localhost", Port, + [binary, {active, false}, {packet, raw}]), + ok = gen_tcp:close(Socket), + receive after 500 -> ok end, + true = is_process_alive(AcceptorPid). + ssl_echo(Config) -> {ok, _} = ranch:start_listener(ssl_echo, 1, ranch_ssl, [{port, 0}, -- cgit v1.2.3