Commit 40b433e6 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net: check for canceled context before starting Windows DNS lookup

Fixes #31950

Change-Id: Id9bcd51a8b49523eeecbd0d8d527372a0b8d8760
Reviewed-on: https://go-review.googlesource.com/c/go/+/177038
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 1956b28a
......@@ -138,11 +138,14 @@ func (r *Resolver) lookupIP(ctx context.Context, network, name string) ([]IPAddr
err error
}
ch := make(chan ret, 1)
go func() {
addr, err := getaddr()
ch <- ret{addrs: addr, err: err}
}()
var ch chan ret
if ctx.Err() == nil {
ch = make(chan ret, 1)
go func() {
addr, err := getaddr()
ch <- ret{addrs: addr, err: err}
}()
}
select {
case r := <-ch:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment