aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-16 06:54:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-16 06:54:38 +0000
commitabf832f4357b02ab40a1bbcb6e59bbc1c35d2817 (patch)
treeaf6cb33b4cea4c9cbfae9bbd3149f115103d4b0e /file.c
parent6291c6ad77a0587d3d7d5461d969f1bc9bbe866d (diff)
downloadruby-abf832f4357b02ab40a1bbcb6e59bbc1c35d2817.tar.gz
file.c: non-blocking open
* file.c (rb_file_load_ok): open in non-blocking mode withoout releasing GVL. don't care about others than regular files and directories. [ruby-dev:49272] [Bug #11559] * ruby.c (load_file_internal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/file.c b/file.c
index f2b760aa0c..5a5fcde229 100644
--- a/file.c
+++ b/file.c
@@ -26,7 +26,6 @@
#include "internal.h"
#include "ruby/io.h"
#include "ruby/util.h"
-#include "ruby/thread.h"
#include "dln.h"
#include "encindex.h"
@@ -5665,25 +5664,24 @@ 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;
-
- fd = (int)(VALUE)rb_thread_call_without_gvl(loadopen_func, (void *)path, RUBY_UBF_IO, 0);
+ int mode = (O_RDONLY |
+#if defined O_NONBLOCK
+ O_NONBLOCK |
+#elif defined O_NDELAY
+ O_NDELAY |
+#endif
+ 0);
+ int fd = rb_cloexec_open(path, mode, 0);
if (fd == -1) return 0;
rb_update_max_fd(fd);
#if !defined DOSISH
{
struct stat st;
- if (fstat(fd, &st) || !S_ISREG(st.st_mode)) {
+ if (fstat(fd, &st) || S_ISDIR(st.st_mode)) {
ret = 0;
}
}