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

ruby-changes:59066

From: Kazuhiro <ko1@a...>
Date: Wed, 4 Dec 2019 20:57:46 +0900 (JST)
Subject: [ruby-changes:59066] a0bc0e1ba1 (master): Fix thread leak in drb

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

From a0bc0e1ba15e83c72426ac243ea96e6497c49859 Mon Sep 17 00:00:00 2001
From: Kazuhiro NISHIYAMA <zn@m...>
Date: Wed, 4 Dec 2019 18:43:19 +0900
Subject: Fix thread leak in drb


diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
index 5673fa3..2e65477 100644
--- a/lib/drb/drb.rb
+++ b/lib/drb/drb.rb
@@ -1213,6 +1213,10 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1213
       @thread.alive?
     end
 
+    def kill
+      @thread.kill
+    end
+
     def method_missing(msg, *arg, &blk)
       synchronize do
         @wait_ev.wait_until { @status == :wait }
@@ -1281,11 +1285,15 @@ module DRb https://github.com/ruby/ruby/blob/trunk/lib/drb/drb.rb#L1285
         end
       end
     end
-    @pool_proxy = make_pool
+
+    def self.stop_pool
+      @pool_proxy&.kill
+      @pool_proxy = nil
+    end
 
     def self.open(remote_uri)  # :nodoc:
       begin
-        @pool_proxy = make_pool unless @pool_proxy.alive?
+        @pool_proxy = make_pool unless @pool_proxy&.alive?
 
         conn = @pool_proxy.take(remote_uri)
         conn = self.new(remote_uri) unless conn
diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb
index 6b8cd5d..0d3ab0f 100644
--- a/test/drb/drbtest.rb
+++ b/test/drb/drbtest.rb
@@ -116,6 +116,7 @@ module DRbBase https://github.com/ruby/ruby/blob/trunk/test/drb/drbtest.rb#L116
       }
     end
     @drb_service.finish
+    DRb::DRbConn.stop_pool
   end
 end
 
-- 
cgit v0.10.2


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

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