aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-07-28 14:31:40 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-28 14:31:40 -0500
commit19db0b732458347b5237ac90865d62b3fd2157f1 (patch)
treec1131bb6eab4a19cd14fa9eb800e1bca01dc9ad4
parenta5db1488251304ec93256654859b430148f0c506 (diff)
downloadrails-19db0b732458347b5237ac90865d62b3fd2157f1.tar.gz
rails-19db0b732458347b5237ac90865d62b3fd2157f1.tar.bz2
rails-19db0b732458347b5237ac90865d62b3fd2157f1.zip
Added back ActionController::Base.allow_concurrency flag and moved lock down to controller processing.
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb15
-rw-r--r--actionpack/lib/action_controller/dispatcher.rb18
3 files changed, 23 insertions, 12 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 03e011c75c..177c6a354e 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -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]
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