[前][次][番号順一覧][スレッド一覧]

ruby-changes:47180

From: nagachika <ko1@a...>
Date: Mon, 10 Jul 2017 04:36:54 +0900 (JST)
Subject: [ruby-changes:47180] nagachika:r59295 (ruby_2_4): merge revision(s) 59030, 59031: [Backport #13638]

nagachika	2017-07-10 04:36:49 +0900 (Mon, 10 Jul 2017)

  New Revision: 59295

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59295

  Log:
    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.

  Added directories:
    branches/ruby_2_4/ext/-test-/thread_fd_close/
    branches/ruby_2_4/test/-ext-/thread_fd_close/
  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/ext/-test-/thread_fd_close/depend
    branches/ruby_2_4/ext/-test-/thread_fd_close/extconf.rb
    branches/ruby_2_4/ext/-test-/thread_fd_close/thread_fd_close.c
    branches/ruby_2_4/test/-ext-/thread_fd_close/test_thread_fd_close.rb
    branches/ruby_2_4/thread.c
    branches/ruby_2_4/version.h
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 59294)
+++ ruby_2_4/version.h	(revision 59295)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.2"
 #define RUBY_RELEASE_DATE "2017-07-10"
-#define RUBY_PATCHLEVEL 135
+#define RUBY_PATCHLEVEL 136
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 7
Index: ruby_2_4/ext/-test-/thread_fd_close/depend
===================================================================
--- ruby_2_4/ext/-test-/thread_fd_close/depend	(nonexistent)
+++ ruby_2_4/ext/-test-/thread_fd_close/depend	(revision 59295)
@@ -0,0 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/-test-/thread_fd_close/depend#L1
+# AUTOGENERATED DEPENDENCIES START
+thread_fd_close.o: $(RUBY_EXTCONF_H)
+thread_fd_close.o: $(arch_hdrdir)/ruby/config.h
+thread_fd_close.o: $(hdrdir)/ruby/backward.h
+thread_fd_close.o: $(hdrdir)/ruby/defines.h
+thread_fd_close.o: $(hdrdir)/ruby/encoding.h
+thread_fd_close.o: $(hdrdir)/ruby/intern.h
+thread_fd_close.o: $(hdrdir)/ruby/io.h
+thread_fd_close.o: $(hdrdir)/ruby/missing.h
+thread_fd_close.o: $(hdrdir)/ruby/onigmo.h
+thread_fd_close.o: $(hdrdir)/ruby/oniguruma.h
+thread_fd_close.o: $(hdrdir)/ruby/ruby.h
+thread_fd_close.o: $(hdrdir)/ruby/st.h
+thread_fd_close.o: $(hdrdir)/ruby/subst.h
+thread_fd_close.o: thread_fd_close.c
+# AUTOGENERATED DEPENDENCIES END

Property changes on: ruby_2_4/ext/-test-/thread_fd_close/depend
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ruby_2_4/ext/-test-/thread_fd_close/thread_fd_close.c
===================================================================
--- ruby_2_4/ext/-test-/thread_fd_close/thread_fd_close.c	(nonexistent)
+++ ruby_2_4/ext/-test-/thread_fd_close/thread_fd_close.c	(revision 59295)
@@ -0,0 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/-test-/thread_fd_close/thread_fd_close.c#L1
+#include "ruby/ruby.h"
+
+static VALUE
+thread_fd_close(VALUE ign, VALUE fd)
+{
+    rb_thread_fd_close(NUM2INT(fd));
+    return Qnil;
+}
+
+void
+Init_thread_fd_close(void)
+{
+    rb_define_singleton_method(rb_cIO, "thread_fd_close", thread_fd_close, 1);
+}

Property changes on: ruby_2_4/ext/-test-/thread_fd_close/thread_fd_close.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ruby_2_4/ext/-test-/thread_fd_close/extconf.rb
===================================================================
--- ruby_2_4/ext/-test-/thread_fd_close/extconf.rb	(nonexistent)
+++ ruby_2_4/ext/-test-/thread_fd_close/extconf.rb	(revision 59295)
@@ -0,0 +1,2 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/ext/-test-/thread_fd_close/extconf.rb#L1
+# frozen_string_literal: true
+create_makefile('-test-/thread_fd_close')

Property changes on: ruby_2_4/ext/-test-/thread_fd_close/extconf.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ruby_2_4/test/-ext-/thread_fd_close/test_thread_fd_close.rb
===================================================================
--- ruby_2_4/test/-ext-/thread_fd_close/test_thread_fd_close.rb	(nonexistent)
+++ ruby_2_4/test/-ext-/thread_fd_close/test_thread_fd_close.rb	(revision 59295)
@@ -0,0 +1,23 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/-ext-/thread_fd_close/test_thread_fd_close.rb#L1
+# 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

Property changes on: ruby_2_4/test/-ext-/thread_fd_close/test_thread_fd_close.rb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Index: ruby_2_4/thread.c
===================================================================
--- ruby_2_4/thread.c	(revision 59294)
+++ ruby_2_4/thread.c	(revision 59295)
@@ -2227,7 +2227,7 @@ rb_notify_fd_close(int fd) https://github.com/ruby/ruby/blob/trunk/ruby_2_4/thread.c#L2227
 void
 rb_thread_fd_close(int fd)
 {
-    while (rb_notify_fd_close(fd));
+    while (rb_notify_fd_close(fd)) rb_thread_schedule();
 }
 
 /*
Index: ruby_2_4
===================================================================
--- ruby_2_4	(revision 59294)
+++ ruby_2_4	(revision 59295)

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r59030-59031

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]