aboutsummaryrefslogtreecommitdiffstats
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
parent00bbdf4451d0e66f0f7823e77c47ac310614c1c3 (diff)
downloadruby-a0bc0e1ba15e83c72426ac243ea96e6497c49859.tar.gz
Fix thread leak in drb
-rw-r--r--lib/drb/drb.rb12
-rw-r--r--test/drb/drbtest.rb1
2 files changed, 11 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
diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb
index 6b8cd5d3e5..0d3ab0f008 100644
--- a/test/drb/drbtest.rb
+++ b/test/drb/drbtest.rb
@@ -116,6 +116,7 @@ module DRbBase
}
end
@drb_service.finish
+ DRb::DRbConn.stop_pool
end
end