mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@51143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7b2a41d317
commit
3153900973
6 changed files with 44 additions and 6 deletions
|
|
@ -1,3 +1,8 @@
|
|||
Sat Jul 4 23:08:32 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* lib/mkmf.rb (pkg_config): split --libs if --libs-only-l option
|
||||
|
|
|
|||
|
|
@ -686,7 +686,8 @@ compile.$(OBJEXT): {$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc
|
|||
|
||||
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
|
|||
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
|
||||
|
|
|
|||
11
file.c
11
file.c
|
|
@ -26,6 +26,7 @@
|
|||
#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)
|
|||
}
|
||||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -687,4 +687,18 @@ class TestRequire < Test::Unit::TestCase
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#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
|
||||
|
|
|
|||
14
win32/file.c
14
win32/file.c
|
|
@ -1,5 +1,6 @@
|
|||
#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, VALUE dname, int abs_mode, int long_na
|
|||
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)
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue