fix: no main result conn, will fail
This commit is contained in:
parent
db94dc76b4
commit
af97922e94
1 changed files with 9 additions and 4 deletions
|
@ -218,7 +218,6 @@ func concurrentDualStackDialContext(ctx context.Context, network, address string
|
|||
}
|
||||
|
||||
var ips []netip.Addr
|
||||
|
||||
if opt.direct {
|
||||
ips, err = resolver.ResolveAllIP(host)
|
||||
} else {
|
||||
|
@ -298,24 +297,30 @@ func concurrentDialContext(ctx context.Context, network string, ips []netip.Addr
|
|||
if res.isPrimary {
|
||||
return res.Conn, nil
|
||||
} else {
|
||||
if !fallback.done || fallback.error != nil {
|
||||
fallback = res
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if res.isPrimary {
|
||||
preferCount.Add(-1)
|
||||
if preferCount.Load() == 0 && fallback.done {
|
||||
if preferCount.Load() == 0 && fallback.done && fallback.error == nil {
|
||||
return fallback.Conn, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
case <-ctx.Done():
|
||||
if fallback.done {
|
||||
if fallback.done && fallback.error == nil {
|
||||
return fallback.Conn, nil
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if fallback.done && fallback.error == nil {
|
||||
return fallback.Conn, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("all ips %v tcp shake hands failed", ips)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue