ruby-changes:39062
From: nagachika <ko1@a...>
Date: Sat, 4 Jul 2015 23:24:40 +0900 (JST)
Subject: [ruby-changes:39062] nagachika:r51143 (ruby_2_2): merge revision(s) 50887, 50896, 50902: [Backport #11060]
nagachika 2015-07-04 23:24:21 +0900 (Sat, 04 Jul 2015) New Revision: 51143 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51143 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_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/common.mk branches/ruby_2_2/file.c branches/ruby_2_2/test/ruby/test_require.rb branches/ruby_2_2/version.h branches/ruby_2_2/win32/file.c Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 51142) +++ ruby_2_2/ChangeLog (revision 51143) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Sat Jul 4 23:08:32 2015 Nobuyoshi Nakada <nobu@r...> + + * file.c (rb_file_load_ok): try opening file without gvl not to + lock entire process. [Bug #11060] + Sat Jul 4 05:00:48 2015 Nobuyoshi Nakada <nobu@r...> * lib/mkmf.rb (pkg_config): split --libs if --libs-only-l option Index: ruby_2_2/common.mk =================================================================== --- ruby_2_2/common.mk (revision 51142) +++ ruby_2_2/common.mk (revision 51143) @@ -686,7 +686,8 @@ compile.$(OBJEXT): {$(VPATH)}opt_sc.inc https://github.com/ruby/ruby/blob/trunk/ruby_2_2/common.mk#L686 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 @@ -1357,6 +1358,7 @@ file.$(OBJEXT): {$(VPATH)}missing.h https://github.com/ruby/ruby/blob/trunk/ruby_2_2/common.mk#L1358 file.$(OBJEXT): {$(VPATH)}oniguruma.h file.$(OBJEXT): {$(VPATH)}st.h file.$(OBJEXT): {$(VPATH)}subst.h +file.$(OBJEXT): {$(VPATH)}thread.h file.$(OBJEXT): {$(VPATH)}util.h gc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h gc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h Index: ruby_2_2/win32/file.c =================================================================== --- ruby_2_2/win32/file.c (revision 51142) +++ ruby_2_2/win32/file.c (revision 51143) @@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/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> @@ -635,6 +636,14 @@ rb_file_expand_path_internal(VALUE fname https://github.com/ruby/ruby/blob/trunk/ruby_2_2/win32/file.c#L636 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) { @@ -652,9 +661,8 @@ rb_file_load_ok(const char *path) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/win32/file.c#L661 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_2/version.h =================================================================== --- ruby_2_2/version.h (revision 51142) +++ ruby_2_2/version.h (revision 51143) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.3" #define RUBY_RELEASE_DATE "2015-07-04" -#define RUBY_PATCHLEVEL 146 +#define RUBY_PATCHLEVEL 147 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 7 Index: ruby_2_2/test/ruby/test_require.rb =================================================================== --- ruby_2_2/test/ruby/test_require.rb (revision 51142) +++ ruby_2_2/test/ruby/test_require.rb (revision 51143) @@ -687,4 +687,18 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/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 + } + rescue Errno::ENOENT + end unless /mswin|mingw/ =~ RUBY_PLATFORM end Index: ruby_2_2/file.c =================================================================== --- ruby_2_2/file.c (revision 51142) +++ ruby_2_2/file.c (revision 51143) @@ -26,6 +26,7 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/file.c#L26 #include "internal.h" #include "ruby/io.h" #include "ruby/util.h" +#include "ruby/thread.h" #include "dln.h" #ifdef HAVE_UNISTD_H @@ -5599,11 +5600,19 @@ rb_path_check(const char *path) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/file.c#L5600 } #ifndef _WIN32 +static void * +loadopen_func(void *arg) +{ + return (void *)(VALUE)rb_cloexec_open((const char *)arg, O_RDONLY, 0); +} + int 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_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r50887,50896,50902 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/