summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-14 08:20:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-14 08:20:43 +0000
commit0b3ef899f200f4a54433d53f92fbf81f619c67d7 (patch)
tree3bab297ddd904851cdf0f3c9b3b53f3c94eacf49 /win32
parent9b04c1dd420743539c76e3b3826301f78fbbaede (diff)
file.c: open without gvl
* 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/trunk@50887 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 6452aad..92b99a0 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>
@@ -683,6 +684,14 @@ rb_readlink(VALUE path)
return append_wstr(rb_enc_str_new(0, 0, enc), wbuf, len, cp, path_cp, enc);
}
+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)
{
@@ -700,9 +709,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);
}