From da9dfc1dece4fbcdf2a8e8ccdb4914ce4aa3a998 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 19 Nov 2010 18:39:02 -0800 Subject: simpler keepalive check for synchronous models Unicorn 3.x includes HttpParser#next? which will reset the parser for keepalive requests without extra steps. --- lib/rainbows/process_client.rb | 4 ++-- lib/rainbows/revactor.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rainbows/process_client.rb b/lib/rainbows/process_client.rb index 143a7a9..3055b9d 100644 --- a/lib/rainbows/process_client.rb +++ b/lib/rainbows/process_client.rb @@ -40,12 +40,12 @@ module Rainbows::ProcessClient if hp.headers? headers = HH.new(headers) range = make_range!(env, status, headers) and status = range.shift - alive = hp.keepalive? && G.alive + alive = hp.next? && G.alive headers[CONNECTION] = alive ? KEEP_ALIVE : CLOSE client.write(response_header(status, headers)) end write_body(client, body, range) - end while alive && hp.reset.nil? + end while alive # if we get any error, try to write something back to the client # assuming we haven't closed the socket, but don't get hung up # if the socket is already closed or broken. We'll always ensure diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index 9e69251..9569d3e 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -64,12 +64,12 @@ module Rainbows::Revactor if hp.headers? headers = HH.new(headers) range = make_range!(env, status, headers) and status = range.shift - env = hp.keepalive? && G.alive && G.kato > 0 + env = hp.next? && G.alive && G.kato > 0 headers[CONNECTION] = env ? KEEP_ALIVE : CLOSE client.write(response_header(status, headers)) end write_body(client, body, range) - end while env && hp.reset.nil? + end while env rescue ::Revactor::TCP::ReadError rescue => e Rainbows::Error.write(io, e) -- cgit v1.2.3-24-ge0c7