@@ -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,31 @@ 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 ) ->
591- try ranch :handshake (Ref ) of
592- {ok , Sock } ->
593- Sock
594- catch
592+ ranch_handshake (Ref ) ->
593+ try ranch :handshake (Ref ) catch
595594 % % Don't log on Reason = closed to prevent flooding the log
596595 % % specially since a TCP health check, such as the default
597596 % % (with cluster-operator) readinessProbe periodically opens
598597 % % and closes a connection, as mentioned in
599598 % % https://github.com/rabbitmq/rabbitmq-server/pull/12304
600- exit :{shutdown , {closed , _ } = Reason } ->
601- exit ({ shutdown , Reason } );
602- exit :{shutdown , {Reason , {PeerIp , PeerPort } = PeerInfo }} ->
599+ exit :{shutdown , {closed , _ }} = Error : Stacktrace ->
600+ erlang : raise ( exit , Error , Stacktrace );
601+ exit :{shutdown , {Reason , {PeerIp , PeerPort }}} = Error : Stacktrace ->
603602 PeerAddress = io_lib :format (" ~ts :~tp " , [rabbit_misc :ntoab (PeerIp ), PeerPort ]),
604603 Protocol = ranch_ref_to_protocol (Ref ),
605604 rabbit_log :error (" ~p error during handshake for protocol ~p and peer ~ts " ,
606605 [Reason , Protocol , PeerAddress ]),
607- exit ({ shutdown , { Reason , PeerInfo }} )
606+ erlang : raise ( exit , Error , Stacktrace )
608607 end .
609608
610609tune_buffer_size (Sock , dynamic_buffer ) ->
0 commit comments