From 1b6aa27320f8ae4a34fcb5fbfb83a448449a76b5 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 28 Jun 2013 16:51:32 -0700 Subject: writing the new body can cause the response to be committed and the request thread to return up the stack before the instance variable is assigned. Synchronize so that the ivar is assigned before the other thread can activate. fixes #10984 --- actionpack/lib/action_dispatch/http/response.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index 5697282791..d3696cbb8a 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -210,7 +210,9 @@ module ActionDispatch # :nodoc: if body.respond_to?(:to_path) @stream = body else - @stream = build_buffer self, munge_body_object(body) + synchronize do + @stream = build_buffer self, munge_body_object(body) + end end end -- cgit v1.2.3