From 0b39a636e4ad1900b3250b0eb9cbe75ef214d166 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 29 Nov 2019 21:38:15 +0000 Subject: test_epoll: avoid out-of-FD errors 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 -- cgit v1.2.3-24-ge0c7