From 537a6f7b4752b04a5ce4cb1fb96f1f1e9c407402 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 9 Aug 2013 20:51:16 +0000 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. Copied from master repository. From-SVN: r201637 --- libgo/go/net/cgo_unix.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libgo/go/net/cgo_unix.go b/libgo/go/net/cgo_unix.go index a4d96a86d12..ce54d827c8e 100644 --- a/libgo/go/net/cgo_unix.go +++ b/libgo/go/net/cgo_unix.go @@ -103,6 +103,7 @@ func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err error, complet var hints syscall.Addrinfo hints.Ai_flags = int32(cgoAddrInfoFlags()) + hints.Ai_socktype = syscall.SOCK_STREAM h := syscall.StringBytePtr(name) syscall.Entersyscall() @@ -130,7 +131,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 != syscall.SOCK_STREAM { continue }