mirror of
https://github.com/golang/go
synced 2024-09-30 12:08:32 -06:00
net: don't forget about ongoing DNS lookup if context canceled
Only forget about it if the context timed out, as the comment says. Fixes #20703. Change-Id: Ie6234f1a32f85e6bfd052dc24a33aa63b8883c37 Reviewed-on: https://go-review.googlesource.com/45999 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
5ee4858a4c
commit
ec7c6c16e1
@ -185,12 +185,15 @@ func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, err
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
// The DNS lookup timed out for some reason. Force
|
||||
// If the DNS lookup timed out for some reason, force
|
||||
// future requests to start the DNS lookup again
|
||||
// rather than waiting for the current lookup to
|
||||
// complete. See issue 8602.
|
||||
err := mapErr(ctx.Err())
|
||||
lookupGroup.Forget(host)
|
||||
ctxErr := ctx.Err()
|
||||
if ctxErr == context.DeadlineExceeded {
|
||||
lookupGroup.Forget(host)
|
||||
}
|
||||
err := mapErr(ctxErr)
|
||||
if trace != nil && trace.DNSDone != nil {
|
||||
trace.DNSDone(nil, false, err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user