From ec7c6c16e14a46d907c7dc95662093f0ed846143 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 16 Jun 2017 11:48:09 -0700 Subject: [PATCH] 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 Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/net/lookup.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/net/lookup.go b/src/net/lookup.go index abc56de533..4490784236 100644 --- a/src/net/lookup.go +++ b/src/net/lookup.go @@ -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) }