1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Lock middleware has been committed upstream

This commit is contained in:
Joshua Peek 2009-01-17 10:16:31 -06:00
parent 3ee4e00918
commit 515a1a3328
6 changed files with 46 additions and 40 deletions

View file

@ -56,7 +56,6 @@ module ActionController
autoload :Integration, 'action_controller/integration'
autoload :IntegrationTest, 'action_controller/integration'
autoload :Layout, 'action_controller/layout'
autoload :Lock, 'action_controller/lock'
autoload :MiddlewareStack, 'action_controller/middleware_stack'
autoload :MimeResponds, 'action_controller/mime_responds'
autoload :PolymorphicRoutes, 'action_controller/polymorphic_routes'

View file

@ -1,16 +0,0 @@
module ActionController
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

View file

@ -1,4 +1,4 @@
use "ActionController::Lock", :if => lambda {
use "Rack::Lock", :if => lambda {
!ActionController::Base.allow_concurrency
}

View file

@ -1,22 +1,2 @@
module Rack
module Utils
module Multipart
class << self
def parse_multipart_with_rewind(env)
result = parse_multipart_without_rewind(env)
begin
env['rack.input'].rewind
rescue NoMethodError, Errno::ESPIPE
# Handles exceptions raised by input streams that cannot be rewound
# such as when using plain CGI under Apache
end
result
end
alias_method_chain :parse_multipart, :rewind
end
end
end
end
require 'action_controller/rack_ext/lock'
require 'action_controller/rack_ext/multipart'

View file

@ -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

View file

@ -0,0 +1,22 @@
module Rack
module Utils
module Multipart
class << self
def parse_multipart_with_rewind(env)
result = parse_multipart_without_rewind(env)
begin
env['rack.input'].rewind
rescue NoMethodError, Errno::ESPIPE
# Handles exceptions raised by input streams that cannot be rewound
# such as when using plain CGI under Apache
end
result
end
alias_method_chain :parse_multipart, :rewind
end
end
end
end