From 515a1a332808eb7c2f9c006fc1903e1e8555b7fa Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 17 Jan 2009 10:16:31 -0600 Subject: Lock middleware has been committed upstream --- actionpack/lib/action_controller/rack_ext/lock.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 actionpack/lib/action_controller/rack_ext/lock.rb (limited to 'actionpack/lib/action_controller/rack_ext/lock.rb') diff --git a/actionpack/lib/action_controller/rack_ext/lock.rb b/actionpack/lib/action_controller/rack_ext/lock.rb new file mode 100644 index 0000000000..9bf1889065 --- /dev/null +++ b/actionpack/lib/action_controller/rack_ext/lock.rb @@ -0,0 +1,21 @@ +module Rack + # Rack::Lock was commited to Rack core + # http://github.com/rack/rack/commit/7409b0c + # Remove this when Rack 1.0 is released + unless defined? Lock + class Lock + FLAG = 'rack.multithread'.freeze + + def initialize(app, lock = Mutex.new) + @app, @lock = app, lock + end + + def call(env) + old, env[FLAG] = env[FLAG], false + @lock.synchronize { @app.call(env) } + ensure + env[FLAG] = old + end + end + end +end -- cgit v1.2.3