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

* lib/resolv.rb (Resolv::DNS::Requester#request): rescue ECONNREFUSED.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-05-29 00:06:17 +00:00
parent 2dce743725
commit 089d2ddda4
3 changed files with 25 additions and 1 deletions

View file

@ -1,3 +1,7 @@
Sat May 29 09:04:06 2010 Tanaka Akira <akr@fsij.org>
* lib/resolv.rb (Resolv::DNS::Requester#request): rescue ECONNREFUSED.
Sat May 29 08:46:29 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* gc.c (allocate_sorted_heaps, before_gc_sweep, gc_sweep): removed

View file

@ -638,7 +638,13 @@ class Resolv
if !select_result
raise ResolvTimeout
end
reply, from = recv_reply(select_result[0])
begin
reply, from = recv_reply(select_result[0])
rescue Errno::ECONNREFUSED
# No name server running on the server?
# Don't wait anymore.
raise ResolvTimeout
end
begin
msg = Message.decode(reply)
rescue DecodeError

View file

@ -104,4 +104,18 @@ class TestResolvDNS < Test::Unit::TestCase
end
}
end
def test_no_server
u = UDPSocket.new
u.bind("127.0.0.1", 0)
_, port, _, host = u.addr
u.close
# A rase condition here.
# Another program may use the port.
# But no way to prevent it.
Resolv::DNS.open(:nameserver_port => [[host, port]]) {|dns|
assert_equal([], dns.getresources("test-no-server.example.org", Resolv::DNS::Resource::IN::A))
}
end
end