aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_dispatch/middleware/load_interlock.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/load_interlock.rb b/actionpack/lib/action_dispatch/middleware/load_interlock.rb
index cbe8d750fe..07f498319c 100644
--- a/actionpack/lib/action_dispatch/middleware/load_interlock.rb
+++ b/actionpack/lib/action_dispatch/middleware/load_interlock.rb
@@ -1,12 +1,21 @@
require 'active_support/dependencies'
-require 'rack/lock'
+require 'rack/body_proxy'
module ActionDispatch
- class LoadInterlock < ::Rack::Lock
- FLAG = 'activesupport.dependency_race'.freeze
+ class LoadInterlock
+ def initialize(app)
+ @app = app
+ end
- def initialize(app, mutex = ::ActiveSupport::Dependencies.interlock)
- super
+ 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