aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
authorAliaksey Kandratsenka <alk@tut.by>2008-10-02 21:06:22 +0300
committerMichael Koziarski <michael@koziarski.com>2008-10-04 18:25:08 +0200
commitb437a7d34e86c16a211171d491e805b603f0dc99 (patch)
treeecbb3fa54c96c38e492d9fcbd8f677718d0ef0af /actionpack/lib/action_controller
parentf550c8625739106e957e4260d3d592a9665fc943 (diff)
downloadrails-b437a7d34e86c16a211171d491e805b603f0dc99.tar.gz
rails-b437a7d34e86c16a211171d491e805b603f0dc99.tar.bz2
rails-b437a7d34e86c16a211171d491e805b603f0dc99.zip
Return processing lock to dispatcher, the finer grained lock was incompatible with the reloading in development mode.
This commit also adds ActionController::Dispatcher#dispatch_unlocking -- non-locking version of dispatch. It's named anologously to POSIX {getc,getchar,...}_unlocked functions. Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1170 state:committed]
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/base.rb9
-rw-r--r--actionpack/lib/action_controller/dispatcher.rb14
2 files changed, 14 insertions, 9 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 976bd98bfa..e99e828730 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -290,8 +290,6 @@ module ActionController #:nodoc:
@@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.
@@ -532,12 +530,7 @@ module ActionController #: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 106d9605af..90c8400c11 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,7 +101,7 @@ module ActionController
@output, @request, @response = output, request, response
end
- def dispatch
+ def dispatch_unlocked
begin
run_callbacks :before_dispatch
handle_request
@@ -110,6 +112,16 @@ module ActionController
end
end
+ def dispatch
+ if ActionController::Base.allow_concurrency
+ dispatch_unlocked
+ else
+ @@guard.synchronize do
+ dispatch_unlocked
+ end
+ end
+ end
+
def dispatch_cgi(cgi, session_options)
if cgi ||= self.class.failsafe_response(@output, '400 Bad Request') { CGI.new }
@request = CgiRequest.new(cgi, session_options)