diff options
author | Kazuhiro NISHIYAMA <[email protected]> | 2019-12-04 18:43:19 +0900 |
---|---|---|
committer | Kazuhiro NISHIYAMA <[email protected]> | 2019-12-04 20:57:24 +0900 |
commit | a0bc0e1ba15e83c72426ac243ea96e6497c49859 (patch) | |
tree | e17206804fa2a0051258527ddea0c97ccd0a5a70 | |
parent | 00bbdf4451d0e66f0f7823e77c47ac310614c1c3 (diff) |
Fix thread leak in drb
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2724
-rw-r--r-- | lib/drb/drb.rb | 12 | ||||
-rw-r--r-- | test/drb/drbtest.rb | 1 |
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 |