Skip to content

Commit dc2a0ab

Browse files
committed
Ensure resources are cleaned up
Fixes #1901
1 parent b987346 commit dc2a0ab

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/rabbit_networking.erl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,16 @@ force_connection_event_refresh(Ref) ->
392392
handshake(Ref, ProxyProtocol) ->
393393
case ProxyProtocol of
394394
true ->
395-
{ok, ProxyInfo} = ranch:recv_proxy_header(Ref, 1000),
396-
{ok, Sock} = ranch:handshake(Ref),
397-
setup_socket(Sock),
398-
{ok, {rabbit_proxy_socket, Sock, ProxyInfo}};
395+
case ranch:recv_proxy_header(Ref, 1000) of
396+
{error, Error} ->
397+
rabbit_log:error("error when receiving proxy header: ~p", [Error]),
398+
% The following call will clean up resources then exit
399+
should_never_match = ranch:handshake(Ref);
400+
{ok, ProxyInfo} ->
401+
{ok, Sock} = ranch:handshake(Ref),
402+
setup_socket(Sock),
403+
{ok, {rabbit_proxy_socket, Sock, ProxyInfo}}
404+
end;
399405
false ->
400406
{ok, Sock} = ranch:handshake(Ref),
401407
setup_socket(Sock),

0 commit comments

Comments
 (0)