Commit 338b7abd authored by Mikio Hara's avatar Mikio Hara Committed by Russ Cox

net: fix EAI_BADFLAGS error on freebsd

R=rsc
CC=golang-dev
https://golang.org/cl/4442072
parent 1f590045
......@@ -31,6 +31,7 @@ GOFILES_freebsd=\
port.go\
CGOFILES_freebsd=\
cgo_bsd.go\
cgo_unix.go\
GOFILES_darwin=\
......@@ -42,6 +43,7 @@ GOFILES_darwin=\
port.go\
CGOFILES_darwin=\
cgo_bsd.go\
cgo_unix.go\
GOFILES_linux=\
......@@ -57,6 +59,7 @@ ifeq ($(GOARCH),arm)
GOFILES_linux+=cgo_stub.go
else
CGOFILES_linux=\
cgo_linux.go\
cgo_unix.go
endif
......
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
/*
#include <netdb.h>
*/
import "C"
func cgoAddrInfoMask() C.int {
return C.AI_MASK
}
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
/*
#include <netdb.h>
*/
import "C"
func cgoAddrInfoMask() C.int {
return C.AI_CANONNAME | C.AI_V4MAPPED | C.AI_ALL
}
......@@ -86,7 +86,7 @@ func cgoLookupIPCNAME(name string) (addrs []IP, cname string, err os.Error, comp
// and similarly for IPv6), but in practice setting it causes
// getaddrinfo to return the wrong canonical name on Linux.
// So definitely leave it out.
hints.ai_flags = C.AI_ALL | C.AI_V4MAPPED | C.AI_CANONNAME
hints.ai_flags = (C.AI_ALL | C.AI_V4MAPPED | C.AI_CANONNAME) & cgoAddrInfoMask()
h := C.CString(name)
defer C.free(unsafe.Pointer(h))
......
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