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=-3.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, URIBL_BLOCKED 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 9AE7F20304; Fri, 22 Apr 2016 00:13:12 +0000 (UTC) Date: Fri, 22 Apr 2016 00:13:12 +0000 From: Eric Wong To: yahns-public@yhbt.net Subject: [PATCH] proxy_pass: honor wbuf_persist when ending response Message-ID: <20160422001312.GA3410@dcvr.yhbt.net> References: <20160406062556.10988-1-e@80x24.org> <20160416081712.GA21868@dcvr.yhbt.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160416081712.GA21868@dcvr.yhbt.net> List-Id: If a static file response gets truncated while writing, we set wbuf_persist to false in wbuf_flush of lib/yahns/wbuf_common.rb Thus, we must check wbuf_persist attribute as late as possible before yielding control back to the caller in proxy_response_finish --- A hopefully better version of what I proposed in: https://yhbt.net/yahns-public/20160416081712.GA21868@dcvr.yhbt.net/ lib/yahns/proxy_http_response.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb index d0e3e41..c8a2a42 100644 --- a/lib/yahns/proxy_http_response.rb +++ b/lib/yahns/proxy_http_response.rb @@ -187,7 +187,6 @@ def proxy_response_start(res, tip, kcar, req_res) def proxy_response_finish(kcar, wbuf, req_res) rbuf = Thread.current[:yahns_rbuf] - alive = wbuf.wbuf_persist if len = kcar.body_bytes_left # known Content-Length case tmp = req_res.kgio_tryread(0x2000, rbuf) @@ -233,6 +232,7 @@ def proxy_response_finish(kcar, wbuf, req_res) else # no Content-Length or Transfer-Encoding: chunked, wait on EOF! + alive = wbuf.wbuf_persist case tmp = req_res.kgio_tryread(0x2000, rbuf) when String tmp = chunk_out(tmp) if alive @@ -248,7 +248,7 @@ def proxy_response_finish(kcar, wbuf, req_res) end busy = wbuf.busy and return proxy_busy_mod_blocked(wbuf, busy) - proxy_busy_mod_done(alive) # returns nil + proxy_busy_mod_done(wbuf.wbuf_persist) # returns nil end def proxy_wait_next(qflags) -- EW