Commit ba6cf63c authored by Ian Lance Taylor's avatar Ian Lance Taylor

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
parent 8a904563
......@@ -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
}
......
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