summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-04 14:24:21 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-04 14:24:21 +0000
commit315390097355992c6c671c8b956fa6951ef36569 (patch)
treee0577cb3e7defa2c13bf7366252e40bc22c7eb47 /win32
parent7b2a41d317d12abcb25a1d5e710b36b419859e9d (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_2@51143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/file.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/win32/file.c b/win32/file.c
index 0fb6d5fa67..38b3d12a76 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>
@@ -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);
}