From d4f0fb2901dde71007591c4a4cc1f0b6ad190fbc Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Fri, 20 Mar 2026 16:45:24 +0100 Subject: [PATCH] Fix OTP29 compilation --- src/ranch_conns_sup.erl | 6 ++++-- test/acceptor_SUITE.erl | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ranch_conns_sup.erl b/src/ranch_conns_sup.erl index 79b40faeb2..f34caf9b49 100644 --- a/src/ranch_conns_sup.erl +++ b/src/ranch_conns_sup.erl @@ -86,8 +86,10 @@ start_protocol(SupPid, MonitorRef, Socket) -> -spec active_connections(pid()) -> non_neg_integer(). active_connections(SupPid) -> Tag = erlang:monitor(process, SupPid), - catch erlang:send(SupPid, {?MODULE, active_connections, self(), Tag}, - [noconnect]), + try erlang:send(SupPid, {?MODULE, active_connections, self(), Tag}, [noconnect]) + catch + _:_ -> ok + end, receive {Tag, Ret} -> erlang:demonitor(Tag, [flush]), diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl index 30969f7348..cd7a5aaed7 100644 --- a/test/acceptor_SUITE.erl +++ b/test/acceptor_SUITE.erl @@ -17,6 +17,7 @@ -module(acceptor_SUITE). -compile(export_all). -compile(nowarn_export_all). +-compile(nowarn_deprecated_catch). -dialyzer({nowarn_function, misc_wait_for_connections/1}). %% @todo Remove when specs in ssl are updated to accept local addresses. @@ -600,12 +601,11 @@ misc_connection_alarms(_) -> AlarmCallback = fun (Ref, AlarmName, _, ActiveConns) -> Self ! {connection_alarm, {Ref, AlarmName, length(ActiveConns)}} end, - Alarms0 = #{ - test1 => Alarm1 = #{type => num_connections, threshold => 2, cooldown => 0, callback => AlarmCallback}, - %% The test2 alarm uses the misspelled treshold key to test for backwards compatibility. - %% @TODO: Change to use the proper spelling when treshold gets removed in Ranch 3.0. - test2 => Alarm2 = #{type => num_connections, treshold => 3, cooldown => 0, callback => AlarmCallback} - }, + Alarm1 = #{type => num_connections, threshold => 2, cooldown => 0, callback => AlarmCallback}, + %% The test2 alarm uses the misspelled treshold key to test for backwards compatibility. + %% @TODO: Change to use the proper spelling when treshold gets removed in Ranch 3.0. + Alarm2 = #{type => num_connections, treshold => 3, cooldown => 0, callback => AlarmCallback}, + Alarms0 = #{test1 => Alarm1, test2 => Alarm2}, ConnectOpts = [binary, {active, false}, {packet, raw}], {ok, _} = ranch:start_listener(Name, ranch_tcp,