aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-02-08 06:42:49 +1030
committerMatthew Draper <matthew@trebex.net>2016-02-08 06:42:49 +1030
commit15f6ad3adca89d07c294fe78e2d383055634f6ca (patch)
treee7245fb5ab53ef16a23ae21ce84c79da983375a3 /actionpack
parent7e35cb2987e146de29d50f97a43caef61e7588af (diff)
parent11579b8306dd6303b306ee10c8bc9f7a4a6adea3 (diff)
downloadrails-15f6ad3adca89d07c294fe78e2d383055634f6ca.tar.gz
rails-15f6ad3adca89d07c294fe78e2d383055634f6ca.tar.bz2
rails-15f6ad3adca89d07c294fe78e2d383055634f6ca.zip
Merge pull request #23532 from matthewd/live-interlock
Hand off the interlock to the new thread in AC::Live
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/live.rb51
1 files changed, 28 insertions, 23 deletions
diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb
index acc4507b2d..fc20e7a421 100644
--- a/actionpack/lib/action_controller/metal/live.rb
+++ b/actionpack/lib/action_controller/metal/live.rb
@@ -238,34 +238,39 @@ module ActionController
# response code and headers back up the rack stack, and still process
# the body in parallel with sending data to the client
new_controller_thread {
- t2 = Thread.current
-
- # Since we're processing the view in a different thread, copy the
- # thread locals from the main thread to the child thread. :'(
- locals.each { |k,v| t2[k] = v }
-
- begin
- super(name)
- rescue => e
- if @_response.committed?
- begin
- @_response.stream.write(ActionView::Base.streaming_completion_on_exception) if request.format == :html
- @_response.stream.call_on_error
- rescue => exception
- log_error(exception)
- ensure
- log_error(e)
- @_response.stream.close
+ ActiveSupport::Dependencies.interlock.running do
+ t2 = Thread.current
+
+ # Since we're processing the view in a different thread, copy the
+ # thread locals from the main thread to the child thread. :'(
+ locals.each { |k,v| t2[k] = v }
+
+ begin
+ super(name)
+ rescue => e
+ if @_response.committed?
+ begin
+ @_response.stream.write(ActionView::Base.streaming_completion_on_exception) if request.format == :html
+ @_response.stream.call_on_error
+ rescue => exception
+ log_error(exception)
+ ensure
+ log_error(e)
+ @_response.stream.close
+ end
+ else
+ error = e
end
- else
- error = e
+ ensure
+ @_response.commit!
end
- ensure
- @_response.commit!
end
}
- @_response.await_commit
+ ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
+ @_response.await_commit
+ end
+
raise error if error
end