about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-04-10 07:27:40 +0000
committerEric Wong <normalperson@yhbt.net>2011-04-10 07:27:40 +0000
commitfefd652d6cc5825bebbe164a360c4a06b1399dcb (patch)
tree7fe723aef0a80c31bdc03fc601e375fb51bbee63
parent983e8ff915118d00b683109df0834733b485086d (diff)
downloadkgio-fefd652d6cc5825bebbe164a360c4a06b1399dcb.tar.gz
Ruby 1.9.3dev has better support for it
-rw-r--r--test/test_cross_thread_close.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test_cross_thread_close.rb b/test/test_cross_thread_close.rb
new file mode 100644
index 0000000..d1115d4
--- /dev/null
+++ b/test/test_cross_thread_close.rb
@@ -0,0 +1,26 @@
+require 'test/unit'
+$-w = true
+require 'kgio'
+
+class TestCrossThreadClose < Test::Unit::TestCase
+
+  def test_cross_thread_close
+    host = ENV["TEST_HOST"] || '127.0.0.1'
+    srv = Kgio::TCPServer.new(host, 0)
+    thr = Thread.new do
+      begin
+        srv.kgio_accept
+      rescue => e
+        e
+      end
+    end
+    sleep(0.1) until thr.stop?
+    srv.close
+    unless defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" &&
+           RUBY_VERSION == "1.9.3"
+      thr.run rescue nil
+    end
+    thr.join
+    assert_kind_of IOError, thr.value
+  end
+end