From 167db914edba809ac93db9cd7d2d4da26a6b04c9 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 14 Sep 2015 14:54:15 -0700 Subject: add a lock when allocating the renderer The controller class is shared among threads, so we need to lock when allocating the Renderer. --- actionpack/lib/action_controller/metal/rendering.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'actionpack') 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 -- cgit v1.2.3