[前][次][番号順一覧][スレッド一覧]

ruby-changes:71962

From: Nobuyoshi <ko1@a...>
Date: Wed, 25 May 2022 19:51:00 +0900 (JST)
Subject: [ruby-changes:71962] cd6f87eefc (master): [ruby/timeout] Set the flag surely before return

https://git.ruby-lang.org/ruby.git/commit/?id=cd6f87eefc

From cd6f87eefc35922d21a1889e038c9f50f229004f Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 25 May 2022 19:50:36 +0900
Subject: [ruby/timeout] Set the flag surely before return

https://github.com/ruby/timeout/commit/f3a31abdfb
---
 lib/timeout.rb | 5 +++--
 1 file 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 https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb#L98
   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 https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb#L120
         requests.reject!(&:done?)
       end
     end
+    watcher.thread_variable_set(:"\0__detached_thread__", true)
+    watcher
   end
   private_class_method :create_timeout_thread
 
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]