diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-08 17:41:50 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-08 17:41:50 -0700 |
commit | 37a764b8e0af585b3475a54566816a2ffc52401b (patch) | |
tree | aae783ed1de617f356a0e2e5ec567c290151a40a /actionpack | |
parent | 2da242f63c28fbf476b814b18e184154a12d0f87 (diff) | |
download | rails-37a764b8e0af585b3475a54566816a2ffc52401b.tar.gz rails-37a764b8e0af585b3475a54566816a2ffc52401b.tar.bz2 rails-37a764b8e0af585b3475a54566816a2ffc52401b.zip |
use a sized buffer to prevent the queue being too large
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/metal/live.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/actionpack/lib/action_controller/metal/live.rb b/actionpack/lib/action_controller/metal/live.rb index 43a9e3aa9d..d8fe43b5af 100644 --- a/actionpack/lib/action_controller/metal/live.rb +++ b/actionpack/lib/action_controller/metal/live.rb @@ -33,13 +33,13 @@ module ActionController module Live class Buffer < ActionDispatch::Response::Buffer #:nodoc: def initialize(response) - super(response, Queue.new) + super(response, SizedQueue.new(10)) end def write(string) unless @response.committed? @response.headers["Cache-Control"] = "no-cache" - @response.headers.delete("Content-Length") + @response.headers.delete "Content-Length" end super @@ -47,13 +47,13 @@ module ActionController def each while str = @buf.pop - yield(str) + yield str end end def close super - @buf.push(nil) + @buf.push nil end end @@ -78,7 +78,7 @@ module ActionController end def initialize(status = 200, header = {}, body = []) - header = Header.new(self, header) + header = Header.new self, header super(status, header, body) end @@ -89,11 +89,11 @@ module ActionController private - def build_buffer(response, body) - buf = Live::Buffer.new(response) - body.each { |part| buf.write(part) } - buf - end + def build_buffer(response, body) + buf = Live::Buffer.new response + body.each { |part| buf.write part } + buf + end end def process(name) |