aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/base.rb6
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/webrick_server.rb4
4 files changed, 11 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index c9221c45be..2e4c049788 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*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 a fall-through action for form_remote_tag that'll be used in case Javascript is unavailable #1459 [Scott Barron]. Example:
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index b5983f0e90..243693437f 100755
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -228,6 +228,12 @@ module ActionController #:nodoc:
@@debug_routes = true
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")
# will be converted to "#{template_root}/test/template.rhtml".
class_inheritable_accessor :template_root
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index 444a918a7c..62e7fdcaae 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,6 +1,6 @@
*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]
diff --git a/railties/lib/webrick_server.rb b/railties/lib/webrick_server.rb
index 137c2570ca..71df5432e1 100644
--- a/railties/lib/webrick_server.rb
+++ b/railties/lib/webrick_server.rb
@@ -65,13 +65,13 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
def service(req, res)
begin
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)
raise WEBrick::HTTPStatus::NotFound, "`#{req.path}' not found."
end
end
ensure
- unless RAILS_ENV == 'production'
+ unless ActionController::Base.allow_concurrency
REQUEST_MUTEX.unlock if REQUEST_MUTEX.locked?
end
end