From db5d9aef00703e695335e8357608f7061fda35e9 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Thu, 2 Oct 2008 21:06:22 +0300 Subject: [PATCH] Return processing lock to dispatcher. This fixes class reloading race in development mode. Without this fix class reloading is unguarded and our app easily hits this race. This reverts commit 19db0b732458347b5237ac90865d62b3fd2157f1 "Added back ActionController::Base.allow_concurrency flag and moved lock down to controller processing." --- actionpack/lib/action_controller/base.rb | 15 +-------------- actionpack/lib/action_controller/dispatcher.rb | 18 +++++++++++------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 976bd98bfaf21..ebcef066fa37e 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -284,14 +284,6 @@ class Base @@debug_routes = true cattr_accessor :debug_routes - # Indicates whether to allow concurrent action processing. Your - # controller actions and any other code they call must also behave well - # when called from concurrent threads. Turned off by default. - @@allow_concurrency = false - cattr_accessor :allow_concurrency - - @@guard = Monitor.new - # Modern REST web services often need to submit complex data to the web application. # The @@param_parsers hash lets you register handlers which will process the HTTP body and add parameters to the # params hash. These handlers are invoked for POST and PUT requests. @@ -532,12 +524,7 @@ def process(request, response, method = :perform_action, *arguments) #:nodoc: assign_names log_processing - - if @@allow_concurrency - send(method, *arguments) - else - @@guard.synchronize { send(method, *arguments) } - end + send(method, *arguments) send_response ensure diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb index bdae5f9d869ba..2e43aea69c003 100644 --- a/actionpack/lib/action_controller/dispatcher.rb +++ b/actionpack/lib/action_controller/dispatcher.rb @@ -2,6 +2,8 @@ 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 @@ -99,13 +101,15 @@ def initialize(output = $stdout, request = nil, response = nil) end def dispatch - begin - run_callbacks :before_dispatch - handle_request - rescue Exception => exception - failsafe_rescue exception - ensure - run_callbacks :after_dispatch, :enumerator => :reverse_each + @@guard.synchronize do + begin + run_callbacks :before_dispatch + handle_request + rescue Exception => exception + failsafe_rescue exception + ensure + run_callbacks :after_dispatch, :enumerator => :reverse_each + end end end