https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112011-05-30T06:50:32ZRuby Issue Tracking SystemRuby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=173222011-05-30T06:50:32Zmetanest (Makoto Kishimoto)
<ul></ul><p>とりあえず思いつかなかったのでパッチでは each_resource_ という名前にしてしまいましたが、fetch_resource という名前でどうでしょうか。</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=185872011-06-28T06:24:16Znahi (Hiroshi Nakamura)nakahiro@gmail.com
<ul><li><strong>Assignee</strong> set to <i>akr (Akira Tanaka)</i></li></ul> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=189812011-07-10T00:21:25Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>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.</p>
<p>Also, I originally suggested then name fetch_resource and thus I support Makoto Kishimoto's proposal about this change.</p>
<p>Lets work to get this updated so that I can add good support for RubyDNS and Ruby 1.9.</p>
<p>Thanks.</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=190342011-07-10T15:38:30Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Target version</strong> changed from <i>1.9.3</i> to <i>2.0.0</i></li></ul> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=191532011-07-14T15:46:03Zmetanest (Makoto Kishimoto)
<ul><li><strong>File</strong> <a href="/attachments/1889">resolv_rb_patch.txt</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1889/resolv_rb_patch.txt">resolv_rb_patch.txt</a> added</li></ul> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=199982011-08-02T22:53:11Zakr (Akira Tanaka)akr@fsij.org
<ul></ul><p>2011/5/27 Makoto Kishimoto <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a>:</p>
<blockquote>
<p>このようなモンキーパッチが(私のコードではありませんが)<br>
<a href="https://github.com/ioquatix/rubydns/blob/master/lib/rubydns/resolv.rb" class="external">https://github.com/ioquatix/rubydns/blob/master/lib/rubydns/resolv.rb</a><br>
<a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Resolv::DNS: Retry via TCP on truncated UDP response (Closed)" href="https://redmine.ruby-lang.org/issues/3835">#3835</a> ( <a href="/issues/3835">[ruby-core:32407]</a> )の結果、動かなくなっていたのでパッチを検討していたわけですが、<br>
結論としてresolv.rbに以下のようなリファクタリングを施すのがいいのではないかと考えました。</p>
</blockquote>
<p>なぜそうするのがいいのか書いていないのでなんとも言い難いものがあります。</p>
<p>モンキーパッチがうまくいかないから、という理由は受け入れ難いです。</p>
<h2>後で調べるはめになったときのために、<br>
変更するときには意図をどこかに残しておきたいと思うのですが、<br>
上記はその記述として十分なものとは思えません。</h2>
<p>[田中 哲][たなか あきら][Tanaka Akira]</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=200222011-08-03T10:54:05Zmetanest (Makoto Kishimoto)
<ul></ul><p>元の問題は、lib/resolv.rb が、TCP へのフォールバックに対応して、その際に<br>
make_requester --> make_udp_requester という名前の変更があったために、<br>
(公開インターフェースではない)それに依存していたコードが動かなくなった、<br>
というものです。</p>
<p>しかし、make_requester のような内部の非常に低いレイヤにあるメソッドに<br>
rubydns ライブラリのコードが依存していた理由は、DNS#each_resource<br>
メソッド中に、個々のリソースを取得するコードが一体不可分に含まれてしまって<br>
いるため、DNS プロキシのようなものを作る場合、each_resource メソッド中の<br>
リソース取得部分のコードの duplicate が、このようなライブラリの実装において<br>
不可避であったためです。</p>
<p>パッチで示したように、リソース取得部分を切り離し、また、一種のコールバックで<br>
ある extract_resources を、現状のハードコーディング状態から抽象化する<br>
リファクタリングによって、ライブラリ側でのコード duplicate が必要なくなります。</p>
<p>パッチで追加される fetch_resource メソッドのユースケースとして、<br>
ライブラリ側のコードがどうなるかというパッチを示します。</p>
<p>--- resolv.rb.orig 2011-05-27 18:15:59.000000000 +0900<br>
+++ resolv.rb 2011-08-03 10:38:43.000000000 +0900<br>
@@ -24,6 +24,13 @@<br>
# This allows such responses to be passed upstream with little or no<br>
# modification/reinterpretation.<br>
def query(name, typeclass)</p>
<ul>
<li>
<pre><code> if respond_to?(:fetch_resource) then
</code></pre>
</li>
<li>
<pre><code> fetch_resource(name, typeclass) do |reply, reply_name|
</code></pre>
</li>
<li>
<pre><code> return reply, reply_name
</code></pre>
</li>
<li>
<pre><code> end
</code></pre>
</li>
<li>
<pre><code> return
</code></pre>
</li>
<li>
<pre><code> end
</code></pre>
</li>
<li>
<pre><code> lazy_initialize
requester = make_requester
senders = {}
</code></pre>
</li>
</ul> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=214352011-10-21T11:04:23Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>It would be nice to get some movement on this - I'm getting bug reports from people trying to use 1.9.x and RubyDNS.</p>
<p>Kind regards,<br>
Samuel</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=248862012-03-18T18:46:39Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li></ul> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=253012012-03-28T19:39:03Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>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.</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=253442012-03-29T10:51:04Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>Here is a translation into English for the most recent message from Makoto:</p>
<p>The original problem is that 'lib/resolv.rb' had a fallback to TCP which was broken. There was a patch (<a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Resolv::DNS: Retry via TCP on truncated UDP response (Closed)" href="https://redmine.ruby-lang.org/issues/3835">#3835</a>) which renamed ‘make_requester' to 'make_udp_requester’. This is not a public interface so the code which depended on it stopped working.</p>
<p>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.</p>
<p>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.</p>
<p>A second patch shows how RubyDNS can be simplified once the proposed change is applied.</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=271632012-06-11T20:55:46Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>Hi, still waiting for some progress on this issue. Lots of people are bugging me about it.</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=281472012-07-16T22:42:24Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p><em>Bump</em></p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=281632012-07-17T08:57:10Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/3344">@ioquatix (Samuel Williams)</a> isn't the only one who's interested in it (read: me too).</p> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=318882012-10-28T23:13:10Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Target version</strong> changed from <i>2.0.0</i> to <i>2.6</i></li></ul> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=382932013-04-06T22:16:40Zakr (Akira Tanaka)akr@fsij.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>This issue was solved with changeset r40159.<br>
Makoto, thank you for reporting this issue.<br>
Your contribution to Ruby is greatly appreciated.<br>
May Ruby be with you.</p>
<hr>
<ul>
<li>lib/resolv.rb (Resolv::DNS.fetch_resource): New method to obtain<br>
full result.<br>
<a href="/issues/4788">[ruby-dev:43587]</a> [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: resolv.rb refactoring (Closed)" href="https://redmine.ruby-lang.org/issues/4788">#4788</a>] proposed by Makoto Kishimoto.</li>
</ul> Ruby master - Feature #4788: resolv.rb refactoringhttps://redmine.ruby-lang.org/issues/4788?journal_id=466472014-05-09T23:19:38Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>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.</p>