diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-03 08:51:59 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-03 08:51:59 +0000 |
commit | dffe87c72014a4732282126acc87c898fddb0d81 (patch) | |
tree | 7be2eb3415f43af35d8c6b27eac291c458fa6eba /win32 | |
parent | ee1519777bbd4f57463e23b267653f8f37d7afaa (diff) |
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
Diffstat (limited to 'win32')
-rw-r--r-- | win32/file.c | 14 |
1 files changed, 11 insertions, 3 deletions
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 <winbase.h> #include <wchar.h> @@ -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); } |