@@ -562,7 +562,9 @@ failed_to_recv_proxy_header(Ref, Error) ->
562562 end ,
563563 rabbit_log :debug (Msg , [Error ]),
564564 % The following call will clean up resources then exit
565- _ = catch ranch :handshake (Ref ),
565+ _ = try ranch :handshake (Ref ) catch
566+ _ :_ -> ok
567+ end ,
566568 exit ({shutdown , failed_to_recv_proxy_header }).
567569
568570handshake (Ref , ProxyProtocolEnabled ) ->
@@ -577,34 +579,34 @@ handshake(Ref, ProxyProtocolEnabled, BufferStrategy) ->
577579 {error , protocol_error , Error } ->
578580 failed_to_recv_proxy_header (Ref , Error );
579581 {ok , ProxyInfo } ->
580- Sock = try_ranch_handshake (Ref ),
582+ { ok , Sock } = ranch_handshake (Ref ),
581583 ok = tune_buffer_size (Sock , BufferStrategy ),
582584 {ok , {rabbit_proxy_socket , Sock , ProxyInfo }}
583585 end ;
584586 false ->
585- Sock = try_ranch_handshake (Ref ),
587+ { ok , Sock } = ranch_handshake (Ref ),
586588 ok = tune_buffer_size (Sock , BufferStrategy ),
587589 {ok , Sock }
588590 end .
589591
590- try_ranch_handshake (Ref ) ->
592+ ranch_handshake (Ref ) ->
591593 try ranch :handshake (Ref ) of
592594 {ok , Sock } ->
593- Sock
595+ { ok , Sock }
594596 catch
595597 % % Don't log on Reason = closed to prevent flooding the log
596598 % % specially since a TCP health check, such as the default
597599 % % (with cluster-operator) readinessProbe periodically opens
598600 % % and closes a connection, as mentioned in
599601 % % https://github.com/rabbitmq/rabbitmq-server/pull/12304
600- exit :{shutdown , {closed , _ } = Reason } ->
601- exit ({ shutdown , Reason } );
602- exit :{shutdown , {Reason , {PeerIp , PeerPort } = PeerInfo }} ->
602+ exit :{shutdown , {closed , _ } = Reason } = Error : Stacktrace ->
603+ erlang : raise ( exit , Error , Stacktrace );
604+ exit :{shutdown , {Reason , {PeerIp , PeerPort } = PeerInfo }} = Error : Stacktrace ->
603605 PeerAddress = io_lib :format (" ~ts :~tp " , [rabbit_misc :ntoab (PeerIp ), PeerPort ]),
604606 Protocol = ranch_ref_to_protocol (Ref ),
605607 rabbit_log :error (" ~p error during handshake for protocol ~p and peer ~ts " ,
606608 [Reason , Protocol , PeerAddress ]),
607- exit ({ shutdown , { Reason , PeerInfo }} )
609+ erlang : raise ( exit , Error , Stacktrace )
608610 end .
609611
610612tune_buffer_size (Sock , dynamic_buffer ) ->
0 commit comments