1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_dispatch/middleware/load_interlock.rb
Matthew Draper 48a735aff7 Fix the Interlock middleware
We can't actually lean on Rack::Lock's implementation, so we'll just
copy it instead. It's simple enough that that's not too troubling.
2015-07-09 03:31:31 +09:30

21 lines
478 B
Ruby

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