yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: yahns-public@yhbt.net
Subject: [PATCH 2/5] queue_*: check for closed IO objects
Date: Tue,  7 Jun 2016 07:39:05 +0000	[thread overview]
Message-ID: <20160607073908.31035-3-e@80x24.org> (raw)
In-Reply-To: <20160607073908.31035-1-e@80x24.org>

Using a high max_events may mean some IO objects are closed
after they're retrieved from the kernel but before our Ruby
process has had a chance to get to them.
---
 lib/yahns/queue_epoll.rb  | 1 +
 lib/yahns/queue_kqueue.rb | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/yahns/queue_epoll.rb b/lib/yahns/queue_epoll.rb
index 6d8a6ca..7f5c038 100644
--- a/lib/yahns/queue_epoll.rb
+++ b/lib/yahns/queue_epoll.rb
@@ -44,6 +44,7 @@ def worker_thread(logger, max_events)
       thr_init
       begin
         epoll_wait(max_events) do |_, io| # don't care for flags for now
+          next if io.closed?
 
           # Note: we absolutely must not do anything with io after
           # we've called epoll_ctl on it, io is exclusive to this
diff --git a/lib/yahns/queue_kqueue.rb b/lib/yahns/queue_kqueue.rb
index 531912b..229475c 100644
--- a/lib/yahns/queue_kqueue.rb
+++ b/lib/yahns/queue_kqueue.rb
@@ -53,6 +53,7 @@ def worker_thread(logger, max_events)
       thr_init
       begin
         kevent(nil, max_events) do |_,_,_,_,_,io| # don't care for flags for now
+          next if io.closed?
           # Note: we absolutely must not do anything with io after
           # we've called kevent(...,EV_ADD) on it, io is exclusive to this
           # thread only until kevent(...,EV_ADD) is called on it.

  parent reply	other threads:[~2016-06-07  7:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07  7:39 [PATCH \0/5] another round of proxy-related bugfixes! Eric Wong
2016-06-07  7:39 ` [PATCH 1/5] test_proxy_pass_no_buffering: fix racy test Eric Wong
2016-06-07  7:39 ` Eric Wong [this message]
2016-06-07  7:39 ` [PATCH 3/5] cleanup graceful shutdown handling Eric Wong
2016-06-07  7:39 ` [PATCH 4/5] proxy_pass: more descriptive error messages Eric Wong
2016-06-07  7:39 ` [PATCH 5/5] proxy_pass: fix HTTP/1.0 backends on EOF w/o buffering Eric Wong

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=20160607073908.31035-3-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).