about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-11-29 21:38:15 +0000
committerEric Wong <e@80x24.org>2019-11-29 21:42:06 +0000
commit0b39a636e4ad1900b3250b0eb9cbe75ef214d166 (patch)
treeef97ff12e29d697c4de507ec5fa74fd017051cb8
parent5e01a92551a838f8ee412cd8ffc73221325cb722 (diff)
downloadsleepy_penguin-0b39a636e4ad1900b3250b0eb9cbe75ef214d166.tar.gz
GC works unpredictably, so we need to track and close
IO objects themselves.
-rw-r--r--test/test_epoll.rb5
1 files changed, 4 insertions, 1 deletions
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