Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
* [PATCH] epoll: ensure closing of pipelined clients if required
@ 2013-01-24 19:56 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2013-01-24 19:56 UTC (permalink / raw)
  To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw

on_read normally relies on the close checking in on_readable,
but on_deferred_write_complete may be called from on_writable
instead (bypassing the close check of on_readable).

This affects both Epoll and XEpoll users, but only if they
were sending responses via body#to_path and triggering

While we're at it, favor non-recursive want_more instead of
calling on_readable recursively in ev_write_responses to
prevent stack growth.
  commit 49f70632e2f4a9b84fd4fced7439d0844fed1bbd in "master"
  of git://bogomips.org/rainbows.git

 lib/rainbows/epoll/client.rb | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/rainbows/epoll/client.rb b/lib/rainbows/epoll/client.rb
index f690d85..d72696b 100644
--- a/lib/rainbows/epoll/client.rb
+++ b/lib/rainbows/epoll/client.rb
@@ -102,7 +102,19 @@ module Rainbows::Epoll::Client
       write_response(status, headers, body, alive)
-    on_read(Z) if alive && 0 == @wr_queue.size && 0 != @buf.size
+    # try to read more if we didn't have to buffer writes
+    next_request if alive && 0 == @wr_queue.size
+  end
+  def next_request
+    if 0 == @buf.size
+      want_more
+    else
+      # pipelined request (already in buffer)
+      on_read(Z)
+      return if @wr_queue[0] || closed?
+      close if :close == @state
+    end
   def epoll_run
@@ -120,7 +132,7 @@ module Rainbows::Epoll::Client
   def on_deferred_write_complete
     :close == @state and return close
-    0 == @buf.size ? on_readable : on_read(Z)
+    next_request
   def handle_error(e)
Eric Wong
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Do not quote signatures (like this one) or top post when replying

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-01-24 19:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-24 19:56 [PATCH] epoll: ensure closing of pipelined clients if required Eric Wong

Rainbows! Rack HTTP server user/dev discussion

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhbt.net/rainbows-public
	git clone --mirror http://ou63pmih66umazou.onion/rainbows-public

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 rainbows-public rainbows-public/ https://yhbt.net/rainbows-public \
		rainbows-public@yhbt.net rainbows-public@bogomips.org rainbows-talk@rubyforge.org rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
	public-inbox-index rainbows-public

Example config snippet for mirrors.
Newsgroups are available over NNTP:
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git