From 12a470e86ca8704b8aa206bce4871d2425f28d3f Mon Sep 17 00:00:00 2001 From: Maria Scott Date: Tue, 7 May 2024 13:24:03 +0200 Subject: [PATCH] Extend error reason in case of failed handshake --- src/ranch.erl | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/ranch.erl b/src/ranch.erl index d48c18a6fc..04418d13d1 100644 --- a/src/ranch.erl +++ b/src/ranch.erl @@ -317,15 +317,13 @@ handshake_result(Result, Ref, Transport, CSocket, Timeout) -> {ok, CSocket2, Info} -> self() ! {handshake_continue, Ref, Transport, CSocket2, Timeout}, {continue, Info}; - {error, {tls_alert, _}} -> - ok = Transport:close(CSocket), - exit(normal); - {error, Reason} when Reason =:= timeout; Reason =:= closed -> - ok = Transport:close(CSocket), - exit(normal); {error, Reason} -> + PeerInfo = case Transport:peername(CSocket) of + {ok, Peer} -> Peer; + {error, _} -> undefined + end, ok = Transport:close(CSocket), - error(Reason) + exit({shutdown, Reason, PeerInfo}) end. -spec handshake_cancel(ref()) -> ok.