diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-12-18 12:00:54 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-12-18 12:00:54 -0600 |
commit | 2eb2ec9e635c740684673495ed547d1c0769038d (patch) | |
tree | 55c28e8c3d11823ad15e9815039d8239afe7287a /actionpack/lib/action_controller/lock.rb | |
parent | 3ff6b00ee30d0961f57e3c4b64ec8ff0155aaf2d (diff) | |
download | rails-2eb2ec9e635c740684673495ed547d1c0769038d.tar.gz rails-2eb2ec9e635c740684673495ed547d1c0769038d.tar.bz2 rails-2eb2ec9e635c740684673495ed547d1c0769038d.zip |
Move gaint lock into middleware
Diffstat (limited to 'actionpack/lib/action_controller/lock.rb')
-rw-r--r-- | actionpack/lib/action_controller/lock.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/lock.rb b/actionpack/lib/action_controller/lock.rb new file mode 100644 index 0000000000..b4b0902f18 --- /dev/null +++ b/actionpack/lib/action_controller/lock.rb @@ -0,0 +1,18 @@ +module ActionController + class Lock + def initialize(app) + @app = app + @lock = Mutex.new + 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 + end + end +end |