1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/resolv.rb: retry via TCP if UDP reply is truncated.

fixed by Julian Mehnle.  [ruby-core:32407]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-10-29 21:01:53 +00:00
parent 340bb04efe
commit 2bb96458e7
2 changed files with 25 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Sat Oct 30 05:58:54 2010 Tanaka Akira <akr@fsij.org>
* lib/resolv.rb: retry via TCP if UDP reply is truncated.
fixed by Julian Mehnle. [ruby-core:32407]
Sat Oct 30 00:35:13 2010 Koichi Sasada <ko1@atdot.net>
* iseq.c (iseq_s_compile): fix optional argument.

View file

@ -492,7 +492,7 @@ class Resolv
def each_resource(name, typeclass, &proc)
lazy_initialize
requester = make_requester
requester = make_udp_requester
senders = {}
begin
@config.resolv(name) {|candidate, tout, nameserver, port|
@ -506,7 +506,19 @@ class Resolv
reply, reply_name = requester.request(sender, tout)
case reply.rcode
when RCode::NoError
extract_resources(reply, reply_name, typeclass, &proc)
if reply.tc == 1 and not Requester::TCP === requester
requester.close
# Retry via TCP:
requester = make_tcp_requester
senders = {}
# This will use TCP for all remaining candidates (assuming the
# current candidate does not already respond successfully via
# TCP). This makes sense because we already know the full
# response will not fit in an untruncated UDP packet.
redo
else
extract_resources(reply, reply_name, typeclass, &proc)
end
return
when RCode::NXDomain
raise Config::NXDomain.new(reply_name.to_s)
@ -519,7 +531,7 @@ class Resolv
end
end
def make_requester # :nodoc:
def make_udp_requester # :nodoc:
nameserver_port = @config.nameserver_port
if nameserver_port.length == 1
Requester::ConnectedUDP.new(*nameserver_port[0])
@ -528,6 +540,11 @@ class Resolv
end
end
def make_tcp_requester # :nodoc:
nameserver_port = @config.nameserver_port
return Requester::TCP.new(*nameserver_port[0])
end
def extract_resources(msg, name, typeclass) # :nodoc:
if typeclass < Resource::ANY
n0 = Name.create(name)