def each_resource_(name, typeclass)
lazy_initialize
requester = make_udp_requester
senders = {}
@@ -517,7 +523,7 @@ class Resolv
# response will not fit in an untruncated UDP packet.
redo
else
I have a vested interest in this patch since I am the developer of RubyDNS. This update will allow RubyDNS to hook into resolve.rb more efficiently. Right now, I have to duplicate code in resolve.rb to get the right behaviour.
Also, I originally suggested then name fetch_resource and thus I support Makoto Kishimoto's proposal about this change.
Lets work to get this updated so that I can add good support for RubyDNS and Ruby 1.9.
--- resolv.rb.orig 2011-05-27 18:15:59.000000000 +0900
+++ resolv.rb 2011-08-03 10:38:43.000000000 +0900
@@ -24,6 +24,13 @@
# This allows such responses to be passed upstream with little or no
# modification/reinterpretation.
def query(name, typeclass)
if respond_to?(:fetch_resource) then
fetch_resource(name, typeclass) do |reply, reply_name|
Hi, still having users with problems and no consistent way to solve it. Merging this patch would be a great addition. Let me know if you require any further support or have any questions.
Here is a translation into English for the most recent message from Makoto:
The original problem is that 'lib/resolv.rb' had a fallback to TCP which was broken. There was a patch (#3835) which renamed ‘make_requester' to 'make_udp_requester’. This is not a public interface so the code which depended on it stopped working.
However, the reason why RubyDNS depended on such a method is because the high level interface performs breaks the response up into individual records but we are actually interested in the response in its entirety. This is specifically a problem when creating a DNS proxy where you want to forward requests with minimal changes. Duplicating the code for each_resource was unavoidable in the implementation of RubyDNS.
As in the patch provided by Makoto, code duplication can be reduced by removing the direct connection between each_resource and fetch_resource, and providing a block to be executed per successful response.
A second patch shows how RubyDNS can be simplified once the proposed change is applied.
This issue was solved with changeset r40159.
Makoto, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
lib/resolv.rb (Resolv::DNS.fetch_resource): New method to obtain
full result. [ruby-dev:43587] [Feature #4788] proposed by Makoto Kishimoto.
I'm happy to se this has been completed. I just thought I'd mention that I reimplemented the DNS resolver in RubyDNS using EventMachine as I couldn't wait for this bug fix. The new EventMachine resolver is asynchronous which makes it useful in the event driven server, such as the one in RubyDNS. Thanks for everyone's effort getting this bug resolved.