ruby-changes:39037
From: usa <ko1@a...>
Date: Fri, 3 Jul 2015 17:52:18 +0900 (JST)
Subject: [ruby-changes:39037] usa:r51118 (ruby_2_1): merge revision(s) 50887, 50896, 50902: [Backport #11060]
usa 2015-07-03 17:51:59 +0900 (Fri, 03 Jul 2015) New Revision: 51118 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51118 Log: merge revision(s) 50887,50896,50902: [Backport #11060] * file.c (rb_file_load_ok): try opening file without gvl not to lock entire process. [Bug #11060] Modified directories: branches/ruby_2_1/ Modified files: branches/ruby_2_1/ChangeLog branches/ruby_2_1/common.mk branches/ruby_2_1/file.c branches/ruby_2_1/test/ruby/test_require.rb branches/ruby_2_1/version.h branches/ruby_2_1/win32/file.c Index: ruby_2_1/ChangeLog =================================================================== --- ruby_2_1/ChangeLog (revision 51117) +++ ruby_2_1/ChangeLog (revision 51118) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1 +Fri Jul 3 17:44:27 2015 Nobuyoshi Nakada <nobu@r...> + + * file.c (rb_file_load_ok): try opening file without gvl not to + lock entire process. [Bug #11060] + Tue Jun 30 11:56:24 2015 Eric Wong <e@8...> * numeric.c (bit_coerce): use original value for error message Index: ruby_2_1/common.mk =================================================================== --- ruby_2_1/common.mk (revision 51117) +++ ruby_2_1/common.mk (revision 51118) @@ -678,7 +678,7 @@ load.$(OBJEXT): {$(VPATH)}load.c {$(VPAT https://github.com/ruby/ruby/blob/trunk/ruby_2_1/common.mk#L678 {$(VPATH)}dln.h {$(VPATH)}internal.h $(PROBES_H_INCLUDES) {$(VPATH)}vm_opts.h file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \ $(ENCODING_H_INCLUDES) {$(VPATH)}util.h {$(VPATH)}dln.h \ - {$(VPATH)}internal.h + {$(VPATH)}internal.h {$(VPATH)}thread.h gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \ {$(VPATH)}regex.h $(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) \ {$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h \ @@ -835,7 +835,8 @@ utf_8.$(OBJEXT): {$(VPATH)}utf_8.c {$(VP https://github.com/ruby/ruby/blob/trunk/ruby_2_1/common.mk#L835 win32/win32.$(OBJEXT): {$(VPATH)}win32/win32.c {$(VPATH)}dln.h {$(VPATH)}dln_find.c \ {$(VPATH)}internal.h $(RUBY_H_INCLUDES) $(PLATFORM_D) -win32/file.$(OBJEXT): {$(VPATH)}win32/file.c $(RUBY_H_INCLUDES) $(PLATFORM_D) +win32/file.$(OBJEXT): {$(VPATH)}win32/file.c {$(VPATH)}thread.h \ + $(RUBY_H_INCLUDES) $(PLATFORM_D) $(NEWLINE_C): $(srcdir)/enc/trans/newline.trans $(srcdir)/tool/transcode-tblgen.rb $(Q) $(BASERUBY) "$(srcdir)/tool/transcode-tblgen.rb" -vo $@ $(srcdir)/enc/trans/newline.trans Index: ruby_2_1/win32/file.c =================================================================== --- ruby_2_1/win32/file.c (revision 51117) +++ ruby_2_1/win32/file.c (revision 51118) @@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/file.c#L1 #include "ruby/ruby.h" #include "ruby/encoding.h" +#include "ruby/thread.h" #include "internal.h" #include <winbase.h> #include <wchar.h> @@ -670,6 +671,14 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/file.c#L671 return result; } +static void * +loadopen_func(void *wpath) +{ + return (void *)CreateFileW(wpath, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); +} + int rb_file_load_ok(const char *path) { @@ -686,9 +695,8 @@ rb_file_load_ok(const char *path) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/win32/file.c#L695 ret = 0; } else { - HANDLE h = CreateFileW(wpath, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE h = (HANDLE)rb_thread_call_without_gvl(loadopen_func, (void *)wpath, + RUBY_UBF_IO, 0); if (h != INVALID_HANDLE_VALUE) { CloseHandle(h); } Index: ruby_2_1/version.h =================================================================== --- ruby_2_1/version.h (revision 51117) +++ ruby_2_1/version.h (revision 51118) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1 #define RUBY_VERSION "2.1.7" -#define RUBY_RELEASE_DATE "2015-06-30" -#define RUBY_PATCHLEVEL 369 +#define RUBY_RELEASE_DATE "2015-07-03" +#define RUBY_PATCHLEVEL 370 #define RUBY_RELEASE_YEAR 2015 -#define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 30 +#define RUBY_RELEASE_MONTH 7 +#define RUBY_RELEASE_DAY 3 #include "ruby/version.h" Index: ruby_2_1/test/ruby/test_require.rb =================================================================== --- ruby_2_1/test/ruby/test_require.rb (revision 51117) +++ ruby_2_1/test/ruby/test_require.rb (revision 51118) @@ -687,4 +687,17 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_require.rb#L687 INPUT } end + + def test_loading_fifo_threading + Tempfile.create(%w'fifo .rb') {|f| + f.close + File.unlink(f.path) + File.mkfifo(f.path) + assert_separately(["-", f.path], <<-END, timeout: 3) + th = Thread.current + Thread.start {begin sleep(0.001) end until th.stop?; th.raise(IOError)} + assert_raise(IOError) {load(ARGV[0])} + END + } + end unless /mswin|mingw/ =~ RUBY_PLATFORM end Index: ruby_2_1/file.c =================================================================== --- ruby_2_1/file.c (revision 51117) +++ ruby_2_1/file.c (revision 51118) @@ -26,6 +26,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/file.c#L26 #include "ruby/ruby.h" #include "ruby/io.h" #include "ruby/util.h" +#include "ruby/thread.h" #include "dln.h" #include "internal.h" @@ -5384,6 +5385,12 @@ rb_path_check(const char *path) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/file.c#L5385 } #ifndef _WIN32 +static void * +loadopen_func(void *arg) +{ + return (void *)(VALUE)rb_cloexec_open((const char *)arg, O_RDONLY, 0); +} + #ifdef __native_client__ __attribute__((noinline)) #endif @@ -5391,7 +5398,9 @@ int https://github.com/ruby/ruby/blob/trunk/ruby_2_1/file.c#L5398 rb_file_load_ok(const char *path) { int ret = 1; - int fd = rb_cloexec_open(path, O_RDONLY, 0); + int fd; + + fd = (int)(VALUE)rb_thread_call_without_gvl(loadopen_func, (void *)path, RUBY_UBF_IO, 0); if (fd == -1) return 0; rb_update_max_fd(fd); #if !defined DOSISH Property changes on: ruby_2_1 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r50887,50896,50902 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/