Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: LookupAddr force use of cgo no matter what #12190

Closed
rsc opened this issue Aug 19, 2015 · 3 comments
Closed

net: LookupAddr force use of cgo no matter what #12190

rsc opened this issue Aug 19, 2015 · 3 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Aug 19, 2015

While investigating #12189, found that the new Go 1.5 implementation of LookupAddr always calls cgo first, even when the DNS configuration on the machine does not merit it, and even when GODEBUG=netdns=go is set in the environment. (If the tree was built with CGO_ENABLED=0 ./make.bash then the cgo call fails quickly and the code falls back to the pure Go version. But it is still called.)

Previous releases of Go had no cgo implementation of LookupAddr, so they always used the pure Go version.

Using cgo unconditionally means that a thread is held by a blocked call (except when CGO_ENABLED=0 of course), where in previous releases it was only a goroutine being held. This is a significant resource increase.

It's even worse that setting GODEBUG, which is supposed to keep cgo from being used, does nothing in this case.

LookupAddr should respect GODEBUG and even without GODEBUG it should not use cgo if the resolver config can be handled by pure Go.

@rsc rsc self-assigned this Aug 19, 2015
@rsc rsc added this to the Go1.5 milestone Aug 19, 2015
@mikioh
Copy link
Contributor

mikioh commented Aug 19, 2015

Dupe of #11238? There is golang.org/cl/11233 and it's marked as R=go1.6.

@gopherbot
Copy link

CL https://golang.org/cl/13698 mentions this issue.

@rsc rsc closed this as completed in 773b9b8 Aug 19, 2015
@mikioh
Copy link
Contributor

mikioh commented Aug 20, 2015

Thanks for the investigation and sorry to trouble you. The change looks good to me even though it appends a trailing dot unconditionally when GODEBUG=netdns=cgo and the name is stored in local database such as /etc/hosts. I now think it's fine because /etc/hosts could be considered as a substitute for some DNS RRs; A, AAAA, PTR (and CNAME on some platform), and actually mDNS speaker implementations use it as a source of RRs.

@golang golang locked and limited conversation to collaborators Aug 22, 2016
@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants