From db2fff96c60e740fc6ac6a505f1c6fb69af64645 Mon Sep 17 00:00:00 2001 From: Jan Uhlig Date: Tue, 25 Jun 2024 10:30:28 +0200 Subject: Fix halfway-stopping of listeners * if the process calling ranch:stop_listener crashes before finishing, the stopping procedure is still executed completely * if a listener is terminated but not deleted, calling ranch:stop_listener removes the remnant --- test/acceptor_SUITE.erl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl index ba09697..7144612 100644 --- a/test/acceptor_SUITE.erl +++ b/test/acceptor_SUITE.erl @@ -112,7 +112,8 @@ groups() -> misc_wait_for_connections, misc_multiple_ip_local_socket_opts, misc_connection_alarms, - misc_stop_unknown_listener + misc_stop_unknown_listener, + misc_repeated_start_stop ]}, {supervisor, [ connection_type_supervisor, connection_type_supervisor_separate_from_connection, @@ -665,6 +666,21 @@ misc_stop_unknown_listener(_) -> {error, not_found} = ranch:stop_listener(make_ref()), ok. +misc_repeated_start_stop(_) -> + doc("Ensure that repeated starts and stops of a listener works."), + Name = name(), + lists:foreach( + fun(_) -> + {ok, _} = ranch:start_listener(Name, ranch_tcp, #{}, echo_protocol, []), + true = is_integer(ranch:get_port(Name)), + ok = ranch:stop_listener(Name), + {'EXIT', _} = begin catch ranch:get_port(Name) end + end, + lists:seq(1, 10) + ), + ok. + + %% ssl. ssl_accept_error(_) -> -- cgit v1.2.3