yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH 3/3] proxy_pass: avoid stuck responses in "proxy_buffering: false"
Date: Tue,  5 Jul 2016 13:50:16 +0000	[thread overview]
Message-ID: <20160705135016.14274-4-e@80x24.org> (raw)
In-Reply-To: <20160705135016.14274-1-e@80x24.org>

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(-)

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 @@ def wbuf_flush(client)
   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
-- 
EW


      parent reply	other threads:[~2016-07-05 13:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-05 13:50 [PATCH 0/3] another round of proxy_pass fixes Eric Wong
2016-07-05 13:50 ` [PATCH 1/3] proxy_pass: avoid TOCTTOU race when unbuffering, too Eric Wong
2016-07-05 13:50 ` [PATCH 2/3] proxy_pass: avoid accessing logger in env after hijacking Eric Wong
2016-07-05 13:50 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/yahns/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160705135016.14274-4-e@80x24.org \
    --to=e@80x24.org \
    --cc=yahns-public@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).