diff options
author | Matthew Draper <matthew@trebex.net> | 2015-04-07 05:51:43 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2015-07-09 03:31:31 +0930 |
commit | 48a735aff7032afaf5534613b10c635acead042a (patch) | |
tree | 334f8ce7a204f4e1f61d91818333f1309d376bb5 | |
parent | 383fed5f232630c198847ec573821ede4cf267a9 (diff) | |
download | rails-48a735aff7032afaf5534613b10c635acead042a.tar.gz rails-48a735aff7032afaf5534613b10c635acead042a.tar.bz2 rails-48a735aff7032afaf5534613b10c635acead042a.zip |
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.
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/load_interlock.rb | 19 |
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 |