diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-07-28 14:31:40 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-07-28 14:31:40 -0500 |
commit | 19db0b732458347b5237ac90865d62b3fd2157f1 (patch) | |
tree | c1131bb6eab4a19cd14fa9eb800e1bca01dc9ad4 /actionpack/lib | |
parent | a5db1488251304ec93256654859b430148f0c506 (diff) | |
download | rails-19db0b732458347b5237ac90865d62b3fd2157f1.tar.gz rails-19db0b732458347b5237ac90865d62b3fd2157f1.tar.bz2 rails-19db0b732458347b5237ac90865d62b3fd2157f1.zip |
Added back ActionController::Base.allow_concurrency flag and moved lock down to controller processing.
Diffstat (limited to 'actionpack/lib')
-rwxr-xr-x | actionpack/lib/action_controller/base.rb | 15 | ||||
-rw-r--r-- | actionpack/lib/action_controller/dispatcher.rb | 18 |
2 files changed, 21 insertions, 12 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 5f4a38dac0..ac10a956f3 100755 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -283,6 +283,14 @@ module ActionController #:nodoc: @@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 @@ module ActionController #: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? diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb index 7df987d525..835d8e834e 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 @@ -101,15 +99,13 @@ module ActionController 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 |