From 405435825e90c5f79209946ecd8fc842519b42ba Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 5 Jul 2016 06:58:43 +0000 Subject: proxy_pass: avoid stuck responses in "proxy_buffering: false" Another critical bugfix for this yet-to-be-released feature. By the time we call proxy_unbuffer in proxy_read_body, the req_res socket may be completely drained of readable data and a persistent-connection-capable backend will be waiting for the next request (not knowing we do not yet support persistent connections). This affects both chunked and identity responses from the upstream. --- lib/yahns/wbuf_lite.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/yahns/wbuf_lite.rb b/lib/yahns/wbuf_lite.rb index fa52f54..25daf21 100644 --- a/lib/yahns/wbuf_lite.rb +++ b/lib/yahns/wbuf_lite.rb @@ -33,10 +33,14 @@ class Yahns::WbufLite < Yahns::Wbuf # :nodoc: def wbuf_close(client) wbuf_abort - # resume reading when @blocked is empty + # resume the event loop when @blocked is empty + # The actual Yahns::ReqRes#yahns_step is actually read/write-event + # agnostic, and we should actually watch for writability here since + # the req_res socket itself could be completely drained of readable + # data and just waiting for another request (which we don't support, yet) if @req_res client.hijack_cleanup - Thread.current[:yahns_queue].queue_mod(@req_res, Yahns::Queue::QEV_RD) + Thread.current[:yahns_queue].queue_mod(@req_res, Yahns::Queue::QEV_WR) return :ignore end @wbuf_persist -- cgit v1.2.3-24-ge0c7