diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-14 14:54:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2015-09-14 14:54:33 -0700 |
commit | 167db914edba809ac93db9cd7d2d4da26a6b04c9 (patch) | |
tree | 661bf4ae9fb802a4bf37516619d9354bb5106649 /actionpack/lib/action_controller/metal/rendering.rb | |
parent | 20a76a3cd6966d08cddaf4a4076dc693a3247227 (diff) | |
download | rails-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/lib/action_controller/metal/rendering.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/rendering.rb | 6 |
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 |