From dffe87c72014a4732282126acc87c898fddb0d81 Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 3 Jul 2015 08:51:59 +0000 Subject: 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_1@51118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/file.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'win32') diff --git a/win32/file.c b/win32/file.c index d0e0864b3f..de66e8cb95 100644 --- a/win32/file.c +++ b/win32/file.c @@ -1,5 +1,6 @@ #include "ruby/ruby.h" #include "ruby/encoding.h" +#include "ruby/thread.h" #include "internal.h" #include #include @@ -670,6 +671,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) { @@ -686,9 +695,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); } -- cgit v1.2.3