aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/dependencies.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2015-07-20 08:09:21 +0930
committerMatthew Draper <matthew@trebex.net>2015-07-20 09:14:10 +0930
commitbd31aec9c33453e0ba96aec614e56958784e6b8d (patch)
tree58cdcf70d61a52bd4df139c8cefbdebe3bd06621 /activesupport/lib/active_support/dependencies.rb
parent6ffec3c16c0ee0b0ab4643907af1f2ed80a71a9a (diff)
downloadrails-bd31aec9c33453e0ba96aec614e56958784e6b8d.tar.gz
rails-bd31aec9c33453e0ba96aec614e56958784e6b8d.tar.bz2
rails-bd31aec9c33453e0ba96aec614e56958784e6b8d.zip
We need stricter locking before we can unload
Specifically, the "loose upgrades" behaviour that allows us to obtain an exclusive right to load things while other requests are in progress (but waiting on the exclusive lock for themselves) prevents us from treating load & unload interchangeably: new things appearing is fine, but they do *not* expect previously-present constants to vanish. We can still use loose upgrades for unloading -- once someone has decided to unload, they don't really care if someone else gets there first -- it just needs to be tracked separately.
Diffstat (limited to 'activesupport/lib/active_support/dependencies.rb')
-rw-r--r--activesupport/lib/active_support/dependencies.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index fc6f822969..18555fbcba 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -37,6 +37,13 @@ module ActiveSupport #:nodoc:
Dependencies.interlock.loading { yield }
end
+ # Execute the supplied block while holding an exclusive lock,
+ # preventing any other thread from being inside a #run_interlock
+ # block at the same time
+ def self.unload_interlock
+ Dependencies.interlock.unloading { yield }
+ end
+
# :nodoc:
# Should we turn on Ruby warnings on the first load of dependent files?
@@ -348,7 +355,7 @@ module ActiveSupport #:nodoc:
def clear
log_call
- Dependencies.load_interlock do
+ Dependencies.unload_interlock do
loaded.clear
loading.clear
remove_unloadable_constants!