Added back ActionController::Base.allow_concurrency flag and moved lock down to controller processing.

This commit is contained in:
Joshua Peek 2008-07-28 14:31:40 -05:00
parent a5db148825
commit 19db0b7324
3 changed files with 23 additions and 12 deletions

@ -1,5 +1,7 @@
*Edge*
* Added back ActionController::Base.allow_concurrency flag [Josh Peek]
* AbstractRequest.relative_url_root is no longer automatically configured by a HTTP header. It can now be set in your configuration environment with config.action_controller.relative_url_root [Josh Peek]
* Update Prototype to 1.6.0.2 #599 [Patrick Joyce]

@ -283,6 +283,14 @@ 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 <tt>@@param_parsers</tt> hash lets you register handlers which will process the HTTP body and add parameters to the
# <tt>params</tt> hash. These handlers are invoked for POST and PUT requests.
@ -537,7 +545,12 @@ def process(request, response, method = :perform_action, *arguments) #:nodoc:
forget_variables_added_to_assigns
log_processing
send(method, *arguments)
if @@allow_concurrency
send(method, *arguments)
else
@@guard.synchronize { send(method, *arguments) }
end
assign_default_content_type_and_charset
response.prepare! unless component_request?

@ -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
@ -101,15 +99,13 @@ def initialize(output = $stdout, request = nil, response = nil)
end
def dispatch
@@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
begin
run_callbacks :before_dispatch
handle_request
rescue Exception => exception
failsafe_rescue exception
ensure
run_callbacks :after_dispatch, :enumerator => :reverse_each
end
end