From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: yahns-public@yhbt.net Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 8E7CA1FAE5; Fri, 5 Jun 2015 09:10:52 +0000 (UTC) From: Eric Wong To: yahns-public@yhbt.net Cc: Eric Wong Subject: [PATCH] use Unicorn::HttpParser#response_start_sent accessor Date: Fri, 5 Jun 2015 09:10:50 +0000 Message-Id: <1433495450-30724-1-git-send-email-e@80x24.org> List-Id: We don't need to waste a valuable ivar slot on each socket when we know unicorn already maintains this flag for us. --- lib/yahns/http_client.rb | 1 - lib/yahns/http_response.rb | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 620e925..7351171 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -20,7 +20,6 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: # called from acceptor thread def yahns_init @hs = Unicorn::HttpRequest.new - @response_start_sent = false @state = :headers # :body, :trailers, :pipelined, Wbuf, StreamFile @input = nil end diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb index 1ef2bbf..1be28bc 100644 --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -46,7 +46,7 @@ module Yahns::HttpResponse # :nodoc: end def response_start - @response_start_sent ? Z : RESPONSE_START + @hs.response_start_sent ? Z : RESPONSE_START end def response_wait_write(rv) @@ -94,7 +94,6 @@ module Yahns::HttpResponse # :nodoc: def http_response_done(alive) @input = @input.close if @input if alive - @response_start_sent = false # @hs.buf will have data if the client pipelined if @hs.buf.empty? @state = :headers @@ -224,7 +223,7 @@ module Yahns::HttpResponse # :nodoc: # returns nil on success # :wait_readable/:wait_writable/:close for epoll def do_ccc - @response_start_sent = true + @hs.response_start_sent = true wbuf = nil rv = nil CCC_RESPONSE_START.each do |buf| @@ -256,8 +255,8 @@ module Yahns::HttpResponse # :nodoc: # returns :close, :wait_writable, or :wait_readable def http_100_response(env) env.delete("HTTP_EXPECT") =~ /\A100-continue\z/i or return - buf = @response_start_sent ? "100 Continue\r\n\r\nHTTP/1.1 ".freeze - : "HTTP/1.1 100 Continue\r\n\r\n".freeze + buf = @hs.response_start_sent ? "100 Continue\r\n\r\nHTTP/1.1 ".freeze + : "HTTP/1.1 100 Continue\r\n\r\n".freeze case rv = kgio_trywrite(buf) when String -- EW