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: DNS lookup API with timeouts #4890

Closed
jmhodges opened this issue Feb 24, 2013 · 3 comments

Comments

Projects
None yet
4 participants
@jmhodges
Copy link
Contributor

commented Feb 24, 2013

Currently, there's no way to do a DNS lookup with a deadline or duration that the
request must finish within. This would be useful when the user wants to control DNS
lookups at a finer grained level separate from connections and requests. 

There is a lookupHostDeadline function in net/lookup.go, but it is not exposed to the
user.

lookupHostDeadline has a TODO inside it to bring the deadlining down into the name
resolution functions themselves, so solving this issue could involve solving that. Even
an exposed API with the TODO in place would allow users to benefit from future fixes.

This is related to the now closed issue #2631.
@bradfitz

This comment has been minimized.

Copy link
Member

commented Feb 24, 2013

Comment 1:

There are nine Lookup functions in package net.  This would mean adding nine new
functions, taking timeouts.
To understand your motivation for wanting this, were you actually hitting problems with
the number of fds or threads for the DNS/cgo calls?
And which OS? On Linux at least we could use getaddrinfo_a (see
http://www.imperialviolet.org/2005/06/01/asynchronous-dns-lookups-with-glibc.html and
http://www.kernel.org/doc/man-pages/online/pages/man3/getaddrinfo_a.3.html) but even
that API doesn't really seem to do timeouts efficiently, probably because the underlying
NSS / resolver(3) mechanisms don't really support timeouts.
Your best bet probably is to not use the system's DNS facilities and use a pure Go DNS
resolver (maybe https://github.com/miekg/dns, which seems popular), where you'll have
more control.

Labels changed: added priority-someday, removed priority-triage.

Status changed to Thinking.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 12, 2013

Comment 2:

I really think using github.com/miekg/dns is your best bet. We don't even have timeout
control in package net on most systems since we're calling into the C library.

Labels changed: added priority-later, removed priority-someday, go1.1maybe.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Jul 30, 2013

Comment 3:

Status changed to WontFix.

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.