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
This commit is contained in:
RPRX 2023-07-22 06:06:25 +08:00 committed by GitHub
parent e603b97ab4
commit 51769fdde1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {