aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-07-10 15:42:08 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-07-10 15:42:08 -0700
commit8f81f7a73d4a5433fe8af57f706d4d1e37d8459b (patch)
tree6a521f59a2bd976ce6c5974e77e8f30f9df768fc /actionpack
parent17a6e603bbc64157f0fc0b648ae1a4f1db97ca7d (diff)
parent0b93c48bbe74857ead9a9ef56b35f87965edbb49 (diff)
downloadrails-8f81f7a73d4a5433fe8af57f706d4d1e37d8459b.tar.gz
rails-8f81f7a73d4a5433fe8af57f706d4d1e37d8459b.tar.bz2
rails-8f81f7a73d4a5433fe8af57f706d4d1e37d8459b.zip
Merge pull request #17102 from matthewd/load-interlock
Concurrent load interlock (rm Rack::Lock)
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch.rb1
-rw-r--r--actionpack/lib/action_dispatch/middleware/load_interlock.rb21
2 files changed, 22 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb
index dcd3ee0644..f6336c8c7a 100644
--- a/actionpack/lib/action_dispatch.rb
+++ b/actionpack/lib/action_dispatch.rb
@@ -52,6 +52,7 @@ module ActionDispatch
autoload :DebugExceptions
autoload :ExceptionWrapper
autoload :Flash
+ autoload :LoadInterlock
autoload :ParamsParser
autoload :PublicExceptions
autoload :Reloader
diff --git a/actionpack/lib/action_dispatch/middleware/load_interlock.rb b/actionpack/lib/action_dispatch/middleware/load_interlock.rb
new file mode 100644
index 0000000000..07f498319c
--- /dev/null
+++ b/actionpack/lib/action_dispatch/middleware/load_interlock.rb
@@ -0,0 +1,21 @@
+require 'active_support/dependencies'
+require 'rack/body_proxy'
+
+module ActionDispatch
+ class LoadInterlock
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ interlock = ActiveSupport::Dependencies.interlock
+ interlock.start_running
+ response = @app.call(env)
+ body = Rack::BodyProxy.new(response[2]) { interlock.done_running }
+ response[2] = body
+ response
+ ensure
+ interlock.done_running unless body
+ end
+ end
+end