From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Subject: [PATCH] epoll: ensure closing of pipelined clients if required
Date: Thu, 24 Jan 2013 19:56:38 +0000 [thread overview]
Message-ID: <20130124195638.GA21628@dcvr.yhbt.net> (raw)
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
on_deferred_write_complete.
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
else
write_response(status, headers, body, alive)
end
- 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
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
end
def handle_error(e)
--
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying
reply other threads:[~2013-01-24 19:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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: http://yhbt.net/rainbows/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130124195638.GA21628@dcvr.yhbt.net \
--to=normalperson-rmlxzr9ms24@public.gmane.org \
--cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
/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
http://yhbt.net/rainbows.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).