mirror of
https://github.com/golang/go.git
synced 2025-11-10 21:51:05 +00:00
net: respect go vs cgo resolver selection in all lookup routines
This is especially important for LookupAddr, which used to be pure Go (lightweight, one goroutine per call) and without this CL is now unconditionally cgo (heavy, one thread per call). Fixes #12190. Change-Id: I43436a942bc1838b024225893e156f280a1e80cf Reviewed-on: https://go-review.googlesource.com/13698 Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
18d27b2d75
commit
773b9b8452
2 changed files with 22 additions and 13 deletions
|
|
@ -74,19 +74,21 @@ func lookupIP(host string) (addrs []IPAddr, err error) {
|
|||
}
|
||||
|
||||
func lookupPort(network, service string) (int, error) {
|
||||
port, err, ok := cgoLookupPort(network, service)
|
||||
if !ok {
|
||||
port, err = goLookupPort(network, service)
|
||||
if systemConf().canUseCgo() {
|
||||
if port, err, ok := cgoLookupPort(network, service); ok {
|
||||
return port, err
|
||||
}
|
||||
}
|
||||
return port, err
|
||||
return goLookupPort(network, service)
|
||||
}
|
||||
|
||||
func lookupCNAME(name string) (string, error) {
|
||||
cname, err, ok := cgoLookupCNAME(name)
|
||||
if !ok {
|
||||
cname, err = goLookupCNAME(name)
|
||||
if systemConf().canUseCgo() {
|
||||
if cname, err, ok := cgoLookupCNAME(name); ok {
|
||||
return cname, err
|
||||
}
|
||||
}
|
||||
return cname, err
|
||||
return goLookupCNAME(name)
|
||||
}
|
||||
|
||||
func lookupSRV(service, proto, name string) (string, []*SRV, error) {
|
||||
|
|
@ -148,9 +150,10 @@ func lookupTXT(name string) ([]string, error) {
|
|||
}
|
||||
|
||||
func lookupAddr(addr string) ([]string, error) {
|
||||
ptrs, err, ok := cgoLookupPTR(addr)
|
||||
if !ok {
|
||||
ptrs, err = goLookupPTR(addr)
|
||||
if systemConf().canUseCgo() {
|
||||
if ptrs, err, ok := cgoLookupPTR(addr); ok {
|
||||
return ptrs, err
|
||||
}
|
||||
}
|
||||
return ptrs, err
|
||||
return goLookupPTR(addr)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue