about summary refs log tree commit homepage
path: root/test/test_poll.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-05 13:11:53 -0700
committerEric Wong <normalperson@yhbt.net>2011-05-05 13:11:53 -0700
commitc821ebeb851807840f74c4cb4f1a10e691bf222a (patch)
tree858c155749ea65acfb99dd76d0376b85a9413841 /test/test_poll.rb
parentf589a9ae18216e1220bea8f905f33051e88f1ae7 (diff)
downloadkgio-c821ebeb851807840f74c4cb4f1a10e691bf222a.tar.gz
This allows callers to modify the pollset, interrupt
the polling thread, and then poll with the modified
pollset.  This is also important for dealing with
closed IO objects that may have been invalidated
due to GC, too.
Diffstat (limited to 'test/test_poll.rb')
-rw-r--r--test/test_poll.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/test_poll.rb b/test/test_poll.rb
index 1c92223..d99e5aa 100644
--- a/test/test_poll.rb
+++ b/test/test_poll.rb
@@ -70,4 +70,24 @@ class TestPoll < Test::Unit::TestCase
     ensure
       trap(:USR1, orig)
   end
+
+  def test_poll_EINTR_changed
+    ok = false
+    orig = trap(:USR1) { ok = true }
+    pollset = { @rd => Kgio::POLLIN }
+    thr = Thread.new do
+      sleep 0.100
+      pollset[@wr] = Kgio::POLLOUT
+      Process.kill(:USR1, $$)
+    end
+    t0 = Time.now
+    res = Kgio.poll(pollset, 1000)
+    diff = Time.now - t0
+    thr.join
+    assert_equal({@wr => Kgio::POLLOUT}, res)
+    assert diff < 1.0, "diff=#{diff}"
+    assert ok
+    ensure
+      trap(:USR1, orig)
+  end
 end if Kgio.respond_to?(:poll)