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

* lib/webrick/utils.rb (WEBrick::Utils::TimeoutHandler): To prevent

potential deadlocks, Queue is used to tell update of @timeout_info
  instead of sleep and wakeup. [Bug #11742] [ruby-dev:49387]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ngoto 2015-12-18 12:32:53 +00:00
parent 9d30ef596c
commit 0967c1e3ad
2 changed files with 14 additions and 6 deletions

View file

@ -1,3 +1,9 @@
Fri Dec 18 21:26:54 2015 Naohisa Goto <ngotogenome@gmail.com>
* lib/webrick/utils.rb (WEBrick::Utils::TimeoutHandler): To prevent
potential deadlocks, Queue is used to tell update of @timeout_info
instead of sleep and wakeup. [Bug #11742] [ruby-dev:49387]
Fri Dec 18 17:24:09 2015 Koichi Sasada <ko1@atdot.net> Fri Dec 18 17:24:09 2015 Koichi Sasada <ko1@atdot.net>
* compile.c (ibf_load_object_string): use fstring if frozen string. * compile.c (ibf_load_object_string): use fstring if frozen string.

View file

@ -152,6 +152,7 @@ module WEBrick
TimeoutMutex.synchronize{ TimeoutMutex.synchronize{
@timeout_info = Hash.new @timeout_info = Hash.new
} }
@queue = Queue.new
@watcher = Thread.start{ @watcher = Thread.start{
to_interrupt = [] to_interrupt = []
while true while true
@ -173,10 +174,14 @@ module WEBrick
} }
to_interrupt.each {|arg| interrupt(*arg)} to_interrupt.each {|arg| interrupt(*arg)}
if !wakeup if !wakeup
sleep @queue.pop
elsif (wakeup -= now) > 0 elsif (wakeup -= now) > 0
sleep(wakeup) begin
Timeout.timeout(wakeup) { @queue.pop }
rescue Timeout::Error
end
end end
@queue.clear
end end
} }
end end
@ -200,10 +205,7 @@ module WEBrick
@timeout_info[thread] ||= Array.new @timeout_info[thread] ||= Array.new
@timeout_info[thread] << (info = [time, exception]) @timeout_info[thread] << (info = [time, exception])
} }
begin @queue.push nil
@watcher.wakeup
rescue ThreadError
end
return info.object_id return info.object_id
end end