Skip to content

Commit

Permalink
Kill the TimerIdConv thread only for ruby 2.3.1 and lower.
Browse files Browse the repository at this point in the history
https://bugs.ruby-lang.org/issues/12342 has been fixed in 2.3.2+ and
2.4.0+ so we should only do this HACK for 2.3.1 and lower.

Extracted from ManageIQ/manageiq#13104
  • Loading branch information
jrafanie committed May 1, 2017
1 parent 671c6d0 commit ba56d83
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ def teardown
global_id_conv = drb_server.config[:idconv]
drb_server.stop_service
self.drb_server = nil

# This hack was done to prevent ruby from leaking the
# TimerIdConv thread.
# https://bugs.ruby-lang.org/issues/12342 (has been fixed in ruby 2.4.0 preview 1)
# also fixed in ruby_2_3 branch for the 2.3.2 release: https://github.com/ruby/ruby/commit/c20b07d5357d7cb73226b149431a658cde54a697
thread = global_id_conv
.try(:instance_variable_get, '@holder')
.try(:instance_variable_get, '@keeper')
if RUBY_VERSION > "2.3.1"
warn "Remove me: #{__FILE__}:#{__LINE__} and my test. Ruby 2.3.2+ should not be creating timer threads."
if RUBY_VERSION <= "2.3.1"
thread = global_id_conv
.try(:instance_variable_get, '@holder')
.try(:instance_variable_get, '@keeper')
return unless thread

thread.kill
Thread.pass while thread.alive?
end
return unless thread

thread.kill
Thread.pass while thread.alive?
end

def drb_cache_timeout
Expand Down

0 comments on commit ba56d83

Please sign in to comment.