1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added ActionController::Base.allow_concurrency to control whether the application is thread-safe, so multi-threaded servers like WEBrick knows whether to apply a mutex around the performance of each action. Action Pack and Active Record are by default thread-safe, but many applications may not be. Turned off by default.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1487 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-06-23 06:56:12 +00:00
parent 413d10ceec
commit 0c3298f2f2
4 changed files with 11 additions and 3 deletions

View file

@ -1,5 +1,7 @@
*SVN* *SVN*
* Added ActionController::Base.allow_concurrency to control whether the application is thread-safe, so multi-threaded servers like WEBrick knows whether to apply a mutex around the performance of each action. Action Pack and Active Record are by default thread-safe, but many applications may not be. Turned off by default.
* Added TextHelper#word_wrap(text, line_length = 80) #1449 [tuxie@dekadance.se] * Added TextHelper#word_wrap(text, line_length = 80) #1449 [tuxie@dekadance.se]
* Added a fall-through action for form_remote_tag that'll be used in case Javascript is unavailable #1459 [Scott Barron]. Example: * Added a fall-through action for form_remote_tag that'll be used in case Javascript is unavailable #1459 [Scott Barron]. Example:

View file

@ -228,6 +228,12 @@ module ActionController #:nodoc:
@@debug_routes = true @@debug_routes = true
cattr_accessor :debug_routes cattr_accessor :debug_routes
# Controls whether the application is thread-safe, so multi-threaded servers like WEBrick knows whether to apply a mutex
# around the performance of each action. Action Pack and Active Record are by default thread-safe, but many applications
# may not be. Turned off by default.
@@allow_concurrency = false
cattr_accessor :allow_concurrency
# Template root determines the base from which template references will be made. So a call to render("test/template") # Template root determines the base from which template references will be made. So a call to render("test/template")
# will be converted to "#{template_root}/test/template.rhtml". # will be converted to "#{template_root}/test/template.rhtml".
class_inheritable_accessor :template_root class_inheritable_accessor :template_root

View file

@ -1,6 +1,6 @@
*SVN* *SVN*
* Removed the mutex from the WEBrick adapter under the production environment so concurrent requests can be served * Made the WEBrick adapter not use a mutex around action performance if ActionController::Base.allow_concurrency is true (default is false)
* Fixed that mailer generator generated fixtures/plural while units expected fixtures/singular #1457 [Scott Barron] * Fixed that mailer generator generated fixtures/plural while units expected fixtures/singular #1457 [Scott Barron]

View file

@ -65,13 +65,13 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
def service(req, res) def service(req, res)
begin begin
unless handle_file(req, res) unless handle_file(req, res)
REQUEST_MUTEX.lock unless RAILS_ENV == 'production' REQUEST_MUTEX.lock unless ActionController::Base.allow_concurrency
unless handle_dispatch(req, res) unless handle_dispatch(req, res)
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found." raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
end end
end end
ensure ensure
unless RAILS_ENV == 'production' unless ActionController::Base.allow_concurrency
REQUEST_MUTEX.unlock if REQUEST_MUTEX.locked? REQUEST_MUTEX.unlock if REQUEST_MUTEX.locked?
end end
end end