Skip to content

Commit

Permalink
Ensure rack.multithread is set back to original value. Accept externa…
Browse files Browse the repository at this point in the history
…l lock.
  • Loading branch information
jeremy committed Dec 18, 2008
1 parent 788ab84 commit 86abd68
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions 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

0 comments on commit 86abd68

Please sign in to comment.