* [PATCH] test_epoll: avoid out-of-FD errors
@ 2019-11-29 21:38 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2019-11-29 21:38 UTC (permalink / raw)
To: sleepy-penguin
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-11-29 21:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 21:38 [PATCH] test_epoll: avoid out-of-FD errors Eric Wong
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).