aboutsummaryrefslogtreecommitdiffstats
path: root/lib/webrick
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 02:22:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-14 02:22:51 +0000
commit7d909eb218100aa110031e2aadf0fead94146e8b (patch)
tree6b61e355a5c0bb50a9952ae58e3fb09b6266cc62 /lib/webrick
parent8f6fed850a08ffbc7aa9abb2a941faa6c47b3a18 (diff)
downloadruby-7d909eb218100aa110031e2aadf0fead94146e8b.tar.gz
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
Diffstat (limited to 'lib/webrick')
-rw-r--r--lib/webrick/utils.rb10
1 files changed, 7 insertions, 3 deletions
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
##