* ruby.c (open_load_file): use rb_thread_wait_fd() instead of reopen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kosaki 2015-10-18 00:21:03 +00:00
parent ff132bc0f4
commit 698f6648c5
2 changed files with 5 additions and 19 deletions

View File

@ -1,3 +1,7 @@
Sun Oct 18 09:20:17 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* ruby.c (open_load_file): use rb_thread_wait_fd() instead of reopen.
Sun Oct 18 05:11:22 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com> Sun Oct 18 05:11:22 2015 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* ruby.c (open_load_file): reset O_NONBLOCK after open. * ruby.c (open_load_file): reset O_NONBLOCK after open.

20
ruby.c
View File

@ -1726,19 +1726,6 @@ load_file_internal(VALUE argp_v)
return (VALUE)tree; return (VALUE)tree;
} }
#ifdef S_ISFIFO
static void *
loadopen_func(void *arg)
{
int fd;
fd = rb_cloexec_open((const char *)arg, O_RDONLY, 0);
if (fd >= 0)
rb_update_max_fd(fd);
return (void *)(VALUE)fd;
}
#endif
static VALUE static VALUE
open_load_file(VALUE fname_v, int *xflag) open_load_file(VALUE fname_v, int *xflag)
{ {
@ -1793,12 +1780,7 @@ open_load_file(VALUE fname_v, int *xflag)
rb_load_fail(fname_v, strerror(e)); rb_load_fail(fname_v, strerror(e));
} }
if (S_ISFIFO(st.st_mode)) { if (S_ISFIFO(st.st_mode)) {
/* We need to wait if FIFO is empty. So, let's reopen it. */ rb_thread_wait_fd(fd);
(void)close(fd);
fd = (int)(VALUE)rb_thread_call_without_gvl(loadopen_func,
(void *)fname, RUBY_UBF_IO, 0);
if (fd < 0)
rb_load_fail(fname_v, strerror(errno));
} }
} }
#endif #endif