From 51769fdde1ca663dcb08d942618e480bee13109f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 22 Jul 2023 06:06:25 +0800 Subject: [PATCH] H2 transport: Abandon `client` if `client.Do(request)` failed See https://github.com/golang/go/issues/30702 Fixes https://github.com/XTLS/Xray-core/issues/2355 --- transport/internet/http/dialer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 010a95a5..f2e55de8 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -173,6 +173,15 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if err != nil { newError("failed to dial to ", dest).Base(err).AtWarning().WriteToLog(session.ExportIDToError(ctx)) wrc.Close() + { + // Abandon `client` if `client.Do(request)` failed + // See https://github.com/golang/go/issues/30702 + globalDialerAccess.Lock() + if globalDialerMap[dialerConf{dest, streamSettings}] == client { + delete(globalDialerMap, dialerConf{dest, streamSettings}) + } + globalDialerAccess.Unlock() + } return } if response.StatusCode != 200 {