提交 167db914 编写于 作者: A Aaron Patterson

add a lock when allocating the renderer

The controller class is shared among threads, so we need to lock when
allocating the Renderer.
上级 20a76a3c
......@@ -11,10 +11,14 @@ module ClassMethods
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册