diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-30 12:09:10 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-06-30 12:09:10 +0000 |
commit | 4757e396d2f8d8f39807cee32ef569e70dea9b15 (patch) | |
tree | 7a44c3733fef2b6896b9b7732ec5957b3d21b4f2 /test | |
parent | 188ae0dbb13022332db52f65f2c5c6a8e54d77e1 (diff) |
merge revision(s) 59030,59031: [Backport #13638]
thread.c: avoid busy looping on rb_thread_fd_close
We no longer use it this function, but extensions do, and
we need to ensure it continues to work for them.
* thread.c (rb_thread_fd_close): schedule other threads in loop
* ext/-test-/thread_fd_close/thread_fd_close.c: new file
* ext/-test-/thread_fd_close/depend: ditto
* ext/-test-/thread_fd_close/extconf.rb: ditto
* test/-ext-/thread_fd_close/test_thread_fd_close.rb: new test
* properties.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/thread_fd_close/test_thread_fd_close.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/-ext-/thread_fd_close/test_thread_fd_close.rb b/test/-ext-/thread_fd_close/test_thread_fd_close.rb new file mode 100644 index 0000000000..c83b06d672 --- /dev/null +++ b/test/-ext-/thread_fd_close/test_thread_fd_close.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true +require 'test/unit' +require '-test-/thread_fd_close' +require 'io/wait' + +class TestThreadFdClose < Test::Unit::TestCase + + def test_thread_fd_close + IO.pipe do |r, w| + th = Thread.new do + begin + r.read(4) + ensure + w.syswrite('done') + end + end + Thread.pass until th.stop? + IO.thread_fd_close(r.fileno) + assert_equal 'done', r.read(4) + assert_raise(IOError) { th.join } + end + end +end |