diff options
author | Troels Thomsen <troels@thomsen.io> | 2017-11-14 23:22:19 +0100 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-11-15 22:34:55 +0000 |
commit | 6a3d4be3b80054b1d802b73d5a519e252e0f82ed (patch) | |
tree | f3915379b4036160f23f92c15cc1da5fd4b127fa /src/net/lookup.go | |
parent | 3a181dc7bc8fd0c61d6090a85f87c934f1874802 (diff) | |
download | go-6a3d4be3b80054b1d802b73d5a519e252e0f82ed.tar.gz go-6a3d4be3b80054b1d802b73d5a519e252e0f82ed.zip |
net: Forget lookups for canceled contexts
A sequential lookup using any non-canceled context has a risk of
returning the result of the previous lookup for a canceled context (i.e.
an error).
This is already prevented for timed out context by forgetting the host
immediately and extending this to also compare the error to
`context.Canceled` resolves this issue.
Fixes #22724
Change-Id: I7aafa1459a0de4dc5c4332988fbea23cbf4dba07
Reviewed-on: https://go-review.googlesource.com/77670
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/net/lookup.go')
-rw-r--r-- | src/net/lookup.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/net/lookup.go b/src/net/lookup.go index c9f327050a..607953bba5 100644 --- a/src/net/lookup.go +++ b/src/net/lookup.go @@ -200,7 +200,7 @@ func (r *Resolver) LookupIPAddr(ctx context.Context, host string) ([]IPAddr, err // rather than waiting for the current lookup to // complete. See issue 8602. ctxErr := ctx.Err() - if ctxErr == context.DeadlineExceeded { + if ctxErr == context.Canceled || ctxErr == context.DeadlineExceeded { lookupGroup.Forget(host) } err := mapErr(ctxErr) |