summaryrefslogtreecommitdiff
path: root/lib/timeout.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-05-25 19:50:36 +0900
committergit <svn-admin@ruby-lang.org>2022-05-25 19:50:47 +0900
commitcd6f87eefc35922d21a1889e038c9f50f229004f (patch)
tree6d3940545717992f878e456b9b84bc5774a6baf3 /lib/timeout.rb
parent152877079467c2d5558ae2155aa00930f51f7587 (diff)
[ruby/timeout] Set the flag surely before return
https://github.com/ruby/timeout/commit/f3a31abdfb
Diffstat (limited to 'lib/timeout.rb')
-rw-r--r--lib/timeout.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 24ffccb0da..aa9bcaf100 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -98,8 +98,7 @@ module Timeout
private_constant :Request
def self.create_timeout_thread
- Thread.new do
- Thread.current.thread_variable_set(:"\0__detached_thread__", true)
+ watcher = Thread.new do
requests = []
while true
until QUEUE.empty? and !requests.empty? # wait to have at least one request
@@ -121,6 +120,8 @@ module Timeout
requests.reject!(&:done?)
end
end
+ watcher.thread_variable_set(:"\0__detached_thread__", true)
+ watcher
end
private_class_method :create_timeout_thread