diff options
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/lock.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/actionpack/lib/action_controller/lock.rb b/actionpack/lib/action_controller/lock.rb index b4b0902f18..c50762216e 100644 --- a/actionpack/lib/action_controller/lock.rb +++ b/actionpack/lib/action_controller/lock.rb @@ -1,18 +1,16 @@ module ActionController class Lock - def initialize(app) - @app = app - @lock = Mutex.new + FLAG = 'rack.multithread'.freeze + + def initialize(app, lock = Mutex.new) + @app, @lock = app, lock end def call(env) - old_multithread = env["rack.multithread"] - env["rack.multithread"] = false - response = @lock.synchronize do - @app.call(env) - end - env["rack.multithread"] = old_multithread - response + old, env[FLAG] = env[FLAG], false + @lock.synchronize { @app.call(env) } + ensure + env[FLAG] = old end end end |