From 056a26e1ee0152991e884accd037724a0b4dd8bb Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 14 Jul 2015 02:22:51 +0000 Subject: webrick/utils.rb: wakeup immediately * lib/webrick/utils.rb (WEBrick::Utils::TimeoutHandler#register): notify the handler thread of new timeout registration. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/webrick/utils.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb index c6da8449df..da6386c96c 100644 --- a/lib/webrick/utils.rb +++ b/lib/webrick/utils.rb @@ -153,7 +153,7 @@ module WEBrick # instead of creating the timeout handler directly. def initialize @timeout_info = Hash.new - Thread.start{ + @watcher = Thread.start{ while true now = Time.now wakeup = nil @@ -194,8 +194,12 @@ module WEBrick # +exception+:: Exception to raise when timeout elapsed def register(thread, time, exception) @timeout_info[thread] ||= Array.new - @timeout_info[thread] << [time, exception] - return @timeout_info[thread].last.object_id + @timeout_info[thread] << (info = [time, exception]) + begin + @watcher.wakeup + rescue ThreadError + end + return info.object_id end ## -- cgit v1.2.3