Skip to content

net: in cgoLookupIPCNAME(), let C.getaddrinfo() get a hint about network family #25947

Closed
@albertjin

Description

@albertjin

I am talking about the following function in src/net/cgo_unix.go,

func cgoLookupIPCNAME(name string) (addrs []IPAddr, cname string, err error) {
	acquireThread()
	defer releaseThread()

	var hints C.struct_addrinfo
	//TODO: assign a value to hints.ai_family based on network family
	hints.ai_flags = cgoAddrInfoFlags
	hints.ai_socktype = C.SOCK_STREAM

	h := make([]byte, len(name)+1)
	copy(h, name)
	var res *C.struct_addrinfo
	gerrno, err := C.getaddrinfo((*C.char)(unsafe.Pointer(&h[0])), nil, &hints, &res)
	if gerrno != 0 {
        // ...

Under macOS, getaddrinfo() will block for 5 seconds when my router drops all UDP packets of AAAA dns requests. But the requirement is barely about connecting to an IPv4 based server and no AAAA address is needed.

Well, I do reconfigure my route to reply all AAAA queries with responses of an empty record set and the problem is solved. A fix of the library internals will be useful anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions