From 2eb2ec9e635c740684673495ed547d1c0769038d Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 18 Dec 2008 12:00:54 -0600 Subject: Move gaint lock into middleware --- actionpack/lib/action_controller/dispatcher.rb | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'actionpack/lib/action_controller/dispatcher.rb') diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb index c9a9264b6d..aa00eecea7 100644 --- a/actionpack/lib/action_controller/dispatcher.rb +++ b/actionpack/lib/action_controller/dispatcher.rb @@ -2,8 +2,6 @@ module ActionController # Dispatches requests to the appropriate controller and takes care of # reloading the app after each request when Dependencies.load? is true. class Dispatcher - @@guard = Mutex.new - class << self def define_dispatcher_callbacks(cache_classes) unless cache_classes @@ -46,6 +44,7 @@ module ActionController cattr_accessor :middleware self.middleware = MiddlewareStack.new do |middleware| + middleware.use "ActionController::Lock", :if => lambda { !ActionController::Base.allow_concurrency } middleware.use "ActionController::Failsafe" middleware.use "ActionController::SessionManagement::Middleware" end @@ -59,7 +58,7 @@ module ActionController @app = @@middleware.build(lambda { |env| self.dup._call(env) }) end - def dispatch_unlocked + def dispatch begin run_callbacks :before_dispatch handle_request @@ -70,16 +69,6 @@ module ActionController end end - def dispatch - if ActionController::Base.allow_concurrency - dispatch_unlocked - else - @@guard.synchronize do - dispatch_unlocked - end - end - end - # DEPRECATE: Remove CGI support def dispatch_cgi(cgi, session_options) CGIHandler.dispatch_cgi(self, cgi, @output) -- cgit v1.2.3