aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-09-30 01:46:07 +0930
committerMatthew Draper <matthew@trebex.net>2015-07-09 03:31:30 +0930
commit383fed5f232630c198847ec573821ede4cf267a9 (patch)
treee55cca58cf30b7dd03ca5506b9e99ab103677673 /railties
parentc37d47e30897762145835e66ae752cce924af01d (diff)
downloadrails-383fed5f232630c198847ec573821ede4cf267a9.tar.gz
rails-383fed5f232630c198847ec573821ede4cf267a9.tar.bz2
rails-383fed5f232630c198847ec573821ede4cf267a9.zip
Rely on the load interlock for non-caching reloads, too
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application/default_middleware_stack.rb22
-rw-r--r--railties/lib/rails/application/finisher.rb6
-rw-r--r--railties/test/application/middleware_test.rb14
3 files changed, 18 insertions, 24 deletions
diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb
index 14ea073039..88eade5c5a 100644
--- a/railties/lib/rails/application/default_middleware_stack.rb
+++ b/railties/lib/rails/application/default_middleware_stack.rb
@@ -32,26 +32,18 @@ module Rails
middleware.use ::Rack::Lock
- elsif config.allow_concurrency
- # Do nothing, even if we know this is dangerous
+ elsif config.allow_concurrency == :unsafe
+ # Do nothing, even if we know this is dangerous. This is the
+ # historical behaviour for true.
else
- # Default concurrency setting
+ # Default concurrency setting: enabled, but safe
- if config.cache_classes && config.eager_load
- # No lock required
-
- elsif config.cache_classes
- # The load interlock is required, but not a full request
- # lock
+ unless config.cache_classes && config.eager_load
+ # Without cache_classes + eager_load, the load interlock
+ # is required for proper operation
middleware.use ::ActionDispatch::LoadInterlock
-
- else
- # If we're reloading on each request, they all need to be
- # run in isolation
-
- middleware.use ::Rack::Lock
end
end
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb
index 0599e988d9..f8f92792a7 100644
--- a/railties/lib/rails/application/finisher.rb
+++ b/railties/lib/rails/application/finisher.rb
@@ -86,8 +86,10 @@ module Rails
# added in the hook are taken into account.
initializer :set_clear_dependencies_hook, group: :all do
callback = lambda do
- ActiveSupport::DescendantsTracker.clear
- ActiveSupport::Dependencies.clear
+ ActiveSupport::Dependencies.interlock.attempt_loading do
+ ActiveSupport::DescendantsTracker.clear
+ ActiveSupport::Dependencies.clear
+ end
end
if config.reload_classes_only_on_change
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index 0ea2c57c55..d298e8d632 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -26,7 +26,7 @@ module ApplicationTests
assert_equal [
"Rack::Sendfile",
"ActionDispatch::Static",
- "Rack::Lock",
+ "ActionDispatch::LoadInterlock",
"ActiveSupport::Cache::Strategy::LocalCache",
"Rack::Runtime",
"Rack::MethodOverride",
@@ -58,7 +58,7 @@ module ApplicationTests
assert_equal [
"Rack::Sendfile",
"ActionDispatch::Static",
- "Rack::Lock",
+ "ActionDispatch::LoadInterlock",
"ActiveSupport::Cache::Strategy::LocalCache",
"Rack::Runtime",
"ActionDispatch::RequestId",
@@ -128,11 +128,11 @@ module ApplicationTests
assert_includes middleware, "ActionDispatch::LoadInterlock"
end
- test "includes lock if cache_classes is off" do
+ test "includes interlock if cache_classes is off" do
add_to_config "config.cache_classes = false"
boot!
- assert_includes middleware, "Rack::Lock"
- assert_not_includes middleware, "ActionDispatch::LoadInterlock"
+ assert_not_includes middleware, "Rack::Lock"
+ assert_includes middleware, "ActionDispatch::LoadInterlock"
end
test "does not include lock if cache_classes is set and so is eager_load" do
@@ -143,8 +143,8 @@ module ApplicationTests
assert_not_includes middleware, "ActionDispatch::LoadInterlock"
end
- test "does not include lock if allow_concurrency is set" do
- add_to_config "config.allow_concurrency = true"
+ test "does not include lock if allow_concurrency is set to :unsafe" do
+ add_to_config "config.allow_concurrency = :unsafe"
boot!
assert_not_includes middleware, "Rack::Lock"
assert_not_includes middleware, "ActionDispatch::LoadInterlock"