sleepy_penguin RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: sleepy-penguin@bogomips.org
Subject: [PATCH] test_epoll: avoid out-of-FD errors
Date: Fri, 29 Nov 2019 21:38:15 +0000	[thread overview]
Message-ID: <20191129213815.15528-1-e@80x24.org> (raw)

GC works unpredictably, so we need to track and close
IO objects themselves.
---
 test/test_epoll.rb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/test/test_epoll.rb b/test/test_epoll.rb
index 786c5be..80968c7 100644
--- a/test/test_epoll.rb
+++ b/test/test_epoll.rb
@@ -521,8 +521,10 @@ class TestEpoll < Test::Unit::TestCase
   def test_epoll_as_queue
     fl = Epoll::OUT | Epoll::ET
     first = nil
+    to_close = []
     500.times do
-      r, w = IO.pipe
+      r, w = ary = IO.pipe
+      to_close.concat(ary)
       @ep.add(w, fl)
       first ||= begin
         @ep.add(r, Epoll::IN | Epoll::ET)
@@ -533,6 +535,7 @@ class TestEpoll < Test::Unit::TestCase
       @ep.wait(1) { |flags, io| first[1].write('.') if i == 0 }
     end
     @ep.wait(1) { |flags, io| assert_equal(first[0], io) }
+    to_close.each(&:close)
   end
 
   def test_epoll_nest

                 reply	other threads:[~2019-11-29 21:38 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: https://yhbt.net/sleepy_penguin/

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

  git send-email \
    --in-reply-to=20191129213815.15528-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=sleepy-penguin@bogomips.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

	https://yhbt.net/sleepy_penguin.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).