summaryrefslogtreecommitdiff
path: root/lib/drb
diff options
context:
space:
mode:
authorKazuhiro NISHIYAMA <zn@mbf.nifty.com>2019-12-04 18:43:19 +0900
committerKazuhiro NISHIYAMA <znz@users.noreply.github.com>2019-12-04 20:57:24 +0900
commita0bc0e1ba15e83c72426ac243ea96e6497c49859 (patch)
treee17206804fa2a0051258527ddea0c97ccd0a5a70 /lib/drb
parent00bbdf4451d0e66f0f7823e77c47ac310614c1c3 (diff)
Fix thread leak in drb
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2724
Diffstat (limited to 'lib/drb')
-rw-r--r--lib/drb/drb.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
index 5673fa3880..2e65477912 100644
--- a/lib/drb/drb.rb
+++ b/lib/drb/drb.rb
@@ -1213,6 +1213,10 @@ module DRb
@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
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