Issue #4788 has been updated by Samuel Williams.


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.

----------------------------------------
Feature #4788: resolv.rb refactoring
https://bugs.ruby-lang.org/issues/4788#change-46647

* Author: Makoto Kishimoto
* Status: Closed
* Priority: Normal
* Assignee: Akira Tanaka
* Category: lib
* Target version: next minor
----------------------------------------
このようなモンキーパッチが(私のコードではありませんが)
https://github.com/ioquatix/rubydns/blob/master/lib/rubydns/resolv.rb
#3835 ( [ruby-core:32407] )の結果、動かなくなっていたのでパッチを検討していたわけですが、
結論としてresolv.rbに以下のようなリファクタリングを施すのがいいのではないかと考えました。
パッチを添付します。

----

diff --git a/lib/resolv.rb b/lib/resolv.rb
index 1e18893..e9c2432 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -491,6 +491,12 @@ class Resolv
     # #getresource for argument details.

     def each_resource(name, typeclass, &proc)
+      each_resource_(name, typeclass) {|reply, reply_name|
+        extract_resources(reply, reply_name, typeclass, &proc)
+      }
+    end
+
+    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
-              extract_resources(reply, reply_name, typeclass, &proc)
+              yield(reply, reply_name)
             end
             return
           when RCode::NXDomain


---Files--------------------------------
resolv_rb_patch.txt (823 Bytes)
resolv_rb_patch.txt (823 Bytes)


-- 
https://bugs.ruby-lang.org/