From ba6cf63cba611d8d4602781bd8abf5bade2af3ca Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 9 Aug 2013 09:23:27 -0700 Subject: [PATCH] net: give C.getaddrinfo a hint that we only want SOCK_STREAM answers This should be more efficient everywhere, and appears to be required on Solaris. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/12583046 --- src/pkg/net/cgo_unix.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pkg/net/cgo_unix.go b/src/pkg/net/cgo_unix.go index 0c3c56936e..c39ada6ae3 100644 --- a/src/pkg/net/cgo_unix.go +++ b/src/pkg/net/cgo_unix.go @@ -83,6 +83,7 @@ func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err error, complet var hints C.struct_addrinfo hints.ai_flags = cgoAddrInfoFlags() + hints.ai_socktype = C.SOCK_STREAM h := C.CString(name) defer C.free(unsafe.Pointer(h)) @@ -109,7 +110,7 @@ func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err error, complet } } for r := res; r != nil; r = r.ai_next { - // Everything comes back twice, once for UDP and once for TCP. + // We only asked for SOCK_STREAM, but check anyhow. if r.ai_socktype != C.SOCK_STREAM { continue } -- 2.48.1