aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-09-14 14:54:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-09-14 14:54:33 -0700
commit167db914edba809ac93db9cd7d2d4da26a6b04c9 (patch)
tree661bf4ae9fb802a4bf37516619d9354bb5106649 /actionpack
parent20a76a3cd6966d08cddaf4a4076dc693a3247227 (diff)
downloadrails-167db914edba809ac93db9cd7d2d4da26a6b04c9.tar.gz
rails-167db914edba809ac93db9cd7d2d4da26a6b04c9.tar.bz2
rails-167db914edba809ac93db9cd7d2d4da26a6b04c9.zip
add a lock when allocating the renderer
The controller class is shared among threads, so we need to lock when allocating the Renderer.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/rendering.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/rendering.rb b/actionpack/lib/action_controller/metal/rendering.rb
index 4214399b6f..d054450853 100644
--- a/actionpack/lib/action_controller/metal/rendering.rb
+++ b/actionpack/lib/action_controller/metal/rendering.rb
@@ -11,10 +11,14 @@ module ActionController
# Documentation at ActionController::Renderer#render
delegate :render, to: :renderer
+ RENDERER_LOCK = Mutex.new
+
# Returns a renderer class (inherited from ActionController::Renderer)
# for the controller.
def renderer
- @renderer ||= Renderer.for(self)
+ @renderer || RENDERER_LOCK.synchronize do
+ @renderer ||= Renderer.for(self)
+ end
end
end