зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
687c41dc4d
Коммит
6533f070ba
|
@ -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
|
||||
|
|
|
@ -657,16 +657,19 @@ class Resolv
|
|||
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 @@ class TestResolvDNS < Test::Unit::TestCase
|
|||
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 @@ class TestResolvDNS < Test::Unit::TestCase
|
|||
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
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче