diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-18 08:25:29 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-18 08:25:29 +0000 |
commit | 4f83ca015d7131f0990ca03a295a9d0c816f0192 (patch) | |
tree | e252946d824acec8cb0d66f69b55a651328b5db2 /dir.c | |
parent | db54a07c7537b485a2f47385ca304639f5e5ba76 (diff) | |
download | ruby-4f83ca015d7131f0990ca03a295a9d0c816f0192.tar.gz |
Cannot call rb_thread_call_with{out,}_gvl before running VM
* dir.c (opendir_without_gvl, with_gvl_gc_for_fd, opendir_at): check the VM is
already initialized before calling rb_thread_call_with{out,}_gvl().
[Bug #14115]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -76,6 +76,8 @@ char *strchr(char*,char); #include "ruby/util.h" +#define vm_initialized rb_cThread + /* define system APIs */ #ifdef _WIN32 #undef chdir @@ -501,11 +503,15 @@ nogvl_opendir(void *ptr) static DIR * opendir_without_gvl(const char *path) { - union { const char *in; void *out; } u; + if (vm_initialized) { + union { const char *in; void *out; } u; - u.in = path; + u.in = path; - return rb_thread_call_without_gvl(nogvl_opendir, u.out, RUBY_UBF_IO, 0); + return rb_thread_call_without_gvl(nogvl_opendir, u.out, RUBY_UBF_IO, 0); + } + else + return opendir(path); } /* @@ -1420,7 +1426,10 @@ with_gvl_gc_for_fd(void *ptr) static int gc_for_fd_with_gvl(int e) { - return (int)(VALUE)rb_thread_call_with_gvl(with_gvl_gc_for_fd, &e); + if (vm_initialized) + return (int)(VALUE)rb_thread_call_with_gvl(with_gvl_gc_for_fd, &e); + else + return rb_gc_for_fd(e) ? Qtrue : Qfalse; } static void * @@ -1471,7 +1480,10 @@ opendir_at(int basefd, const char *path) oaa.basefd = basefd; oaa.path = path; - return rb_thread_call_without_gvl(nogvl_opendir_at, &oaa, RUBY_UBF_IO, 0); + if (vm_initialized) + return rb_thread_call_without_gvl(nogvl_opendir_at, &oaa, RUBY_UBF_IO, 0); + else + return nogvl_opendir_at(&oaa); } static DIR * |