aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/concurrency
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2015-07-21 11:48:21 +0930
committerMatthew Draper <matthew@trebex.net>2015-07-21 12:03:38 +0930
commite9020ac4310d1b190619769a8a621935d4efc812 (patch)
treef31c0d6537e956f292c45d09fff886aca812ab41 /activesupport/lib/active_support/concurrency
parent4c54b2a9a012296709de5283eada03470d581dc9 (diff)
downloadrails-e9020ac4310d1b190619769a8a621935d4efc812.tar.gz
rails-e9020ac4310d1b190619769a8a621935d4efc812.tar.bz2
rails-e9020ac4310d1b190619769a8a621935d4efc812.zip
Handle thread death during lock acquisition
Specifically, clean up if the thread is killed while it's blocked awaiting the lock... if we get killed on some other arbitrary line, the result remains quite undefined.
Diffstat (limited to 'activesupport/lib/active_support/concurrency')
-rw-r--r--activesupport/lib/active_support/concurrency/share_lock.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/concurrency/share_lock.rb b/activesupport/lib/active_support/concurrency/share_lock.rb
index 39ae9bfb79..ca48164c54 100644
--- a/activesupport/lib/active_support/concurrency/share_lock.rb
+++ b/activesupport/lib/active_support/concurrency/share_lock.rb
@@ -54,10 +54,12 @@ module ActiveSupport
loose_shares = @sharing.delete(Thread.current)
@waiting[Thread.current] = compatible if loose_shares
- @cv.wait_while { busy?(purpose) }
-
- @waiting.delete Thread.current
- @sharing[Thread.current] = loose_shares if loose_shares
+ begin
+ @cv.wait_while { busy?(purpose) }
+ ensure
+ @waiting.delete Thread.current
+ @sharing[Thread.current] = loose_shares if loose_shares
+ end
end
@exclusive_thread = Thread.current
end