aboutsummaryrefslogtreecommitdiff
path: root/src/net/lookup_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/lookup_unix.go')
-rw-r--r--src/net/lookup_unix.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/net/lookup_unix.go b/src/net/lookup_unix.go
index 35f253c1da..be2ced9c39 100644
--- a/src/net/lookup_unix.go
+++ b/src/net/lookup_unix.go
@@ -72,17 +72,20 @@ func (r *Resolver) lookupIP(ctx context.Context, host string) (addrs []IPAddr, e
// cgo not available (or netgo); fall back to Go's DNS resolver
order = hostLookupFilesDNS
}
- return goLookupIPOrder(ctx, host, order)
+ addrs, _, err = goLookupIPCNAMEOrder(ctx, host, order)
+ return
}
func (r *Resolver) lookupPort(ctx context.Context, network, service string) (int, error) {
- // TODO: use the context if there ever becomes a need. Related
- // is issue 15321. But port lookup generally just involves
- // local files, and the os package has no context support. The
- // files might be on a remote filesystem, though. This should
- // probably race goroutines if ctx != context.Background().
if !r.PreferGo && systemConf().canUseCgo() {
if port, err, ok := cgoLookupPort(ctx, network, service); ok {
+ if err != nil {
+ // Issue 18213: if cgo fails, first check to see whether we
+ // have the answer baked-in to the net package.
+ if port, err := goLookupPort(network, service); err == nil {
+ return port, nil
+ }
+ }
return port, err
}
}