From 3a96720e4e0f1d14599b9fae10e210110976e0c5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 2 Aug 2010 01:24:25 +0000 Subject: revactor: implement sendfile and range support Due to the synchronous nature of Revactor, we can be certain sendfile won't overstep the userspace output buffering done by Rev. --- lib/rainbows/revactor.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'lib/rainbows/revactor.rb') diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index 8ec791d..10b7d3c 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -61,15 +61,12 @@ module Rainbows::Revactor if hp.headers? headers = HH.new(headers) - headers[CONNECTION] = if hp.keepalive? && G.alive - KEEP_ALIVE - else - env = false - CLOSE - end + range = make_range!(env, status, headers) and status = range.shift + env = false unless hp.keepalive? && G.alive + headers[CONNECTION] = env ? KEEP_ALIVE : CLOSE client.write(response_header(status, headers)) end - write_body(client, body) + write_body(client, body, range) end while env && env.clear && hp.reset.nil? rescue ::Revactor::TCP::ReadError rescue => e @@ -83,7 +80,8 @@ module Rainbows::Revactor # given a INT, QUIT, or TERM signal) def worker_loop(worker) #:nodoc: init_worker_process(worker) - self.class.__send__(:alias_method, :write_body, :write_body_each) + require 'rainbows/revactor/body' + self.class.__send__(:include, Rainbows::Revactor::Body) RD_ARGS[:timeout] = G.kato if G.kato > 0 nr = 0 limit = worker_connections -- cgit v1.2.3-24-ge0c7