Permalink
Browse files

* lib/resolv.rb (Resolv::DNS): retry IO.select for premature wakeup.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 687c41d commit 6533f070ba616662b7ab7504f7bc2a0827394a89 @akr akr committed Oct 31, 2011
Showing with 14 additions and 5 deletions.
  1. +4 −0 ChangeLog
  2. +6 −3 lib/resolv.rb
  3. +4 −2 test/resolv/test_dns.rb
View
@@ -1,3 +1,7 @@
+Mon Oct 31 21:02:43 2011 Tanaka Akira <akr@fsij.org>
+
+ * lib/resolv.rb (Resolv::DNS): retry IO.select for premature wakeup.
+
Mon Oct 31 20:14:22 2011 Tanaka Akira <akr@fsij.org>
* io.c (fd_set_cloexec): clear CLOEXEC flag for standard file
View
@@ -657,16 +657,19 @@ def initialize
end
def request(sender, tout)
- timelimit = Time.now + tout
+ start = Time.now
+ timelimit = start + tout
sender.send
while true
- now = Time.now
- timeout = timelimit - now
+ before_select = Time.now
+ timeout = timelimit - before_select
if timeout <= 0
raise ResolvTimeout
end
select_result = IO.select(@socks, nil, nil, timeout)
if !select_result
+ after_select = Time.now
+ next if after_select < timelimit
raise ResolvTimeout
end
begin
@@ -114,7 +114,8 @@ def test_query_ipv4_address_timeout
start = Time.now
dns.getresources("foo.example.org", Resolv::DNS::Resource::IN::A)
}
- diff = Time.now - start
+ t2 = Time.now
+ diff = t2 - start
assert rv.empty?, "unexpected: #{rv.inspect} (expected empty)"
assert_operator 0.1, :<=, diff
@@ -123,7 +124,8 @@ def test_query_ipv4_address_timeout
start = Time.now
dns.getresources("foo.example.org", Resolv::DNS::Resource::IN::A)
}
- diff = Time.now - start
+ t2 = Time.now
+ diff = t2 - start
assert rv.empty?, "unexpected: #{rv.inspect} (expected empty)"
assert_operator 0.3, :<=, diff
}

0 comments on commit 6533f07

Please sign in to comment.