Bug #8285

Resolv::DNS: TCP fallback fails with multiple resolvers

Added by Julian Mehnle 12 months ago. Updated 3 months ago.

[ruby-core:<unknown>]
Status:Feedback
Priority:Normal
Assignee:-
Category:lib
Target version:-
ruby -v:ruby 1.8.7 (2011-12-28 patchlevel 357) [i686-darwin11] Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

Since my TCP fallback support patch from #3835 was merged Resolv::DNS would sometimes fail with a @"host/port don't match: :"@ @Resolv::DNS::Requester::RequestError@ exception in @resolv.rb@, line 818 (Ruby 1.9.1). This happens when more than one nameserver is configured and Resolv::DNS is has fallen back to TCP and rotates from the first to the second nameserver (e.g., when there was a timeout in the TCP query to the first nameserver).

ruby-trunk-8285-resolv-tcp-fallback-fix.diff Magnifier (2.51 KB) Julian Mehnle, 04/18/2013 07:36 AM

History

#1 Updated by Julian Mehnle 12 months ago

The problem is caused by my original TCP fallback code reusing a Resolv::DNS::Requester::TCP::Sender object that was initialized for one (the first) nameserver with a Resolv::DNS::Requester::TCP object that was initialized for another (the second) nameserver, and the TCP requester detecting a host/port mismatch between itself and the sender. (The fact that both the requester and the sender are aware of the nameserver's host and port is a design bug in the original code, but I opted not to fix that.)

This patch fixes my original TCP fallback code to keep one sender per requester, thereby avoiding mismatch situations. (Also this patch gracefully handles the nameserver refusing a TCP connection (raised as an Errno::ECONNREFUSED exception) by treating it like a timeout.)

#2 Updated by Julian Mehnle 12 months ago

Why has @monospace@ formatting been disabled in this Redmine? Bleh!

#3 Updated by Julian Mehnle 12 months ago

Also, ruby -v actually is: ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin11]

#4 Updated by Akira Tanaka 3 months ago

After ruby-trunk-8285-resolv-tcp-fallback-fix.diff is applied,
lib/resolv.rb has a syntax error.

% ruby -c lib/resolv.rb
lib/resolv.rb:524: syntax error, unexpected tOP_ASGN
protocol  = protocols[candidate| ||= :udp
                                    ^

#5 Updated by Akira Tanaka 3 months ago

  • Status changed from Open to Feedback

Also available in: Atom PDF