mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
dir: Dir.chdir releases GVL
chdir(2) is subject to all the pathological slowdowns and caveats as open(2) on slow or unreliable filesystems, so ensure other threads can proceed while this is happening. * dir.c (nogvl_chdir): new function * dir.c (dir_chdir): release GVL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
fecb9f8d88
commit
0b0e71ba2b
1 changed files with 13 additions and 1 deletions
14
dir.c
14
dir.c
|
@ -967,10 +967,22 @@ dir_close(VALUE dir)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
static void *
|
||||
nogvl_chdir(void *ptr)
|
||||
{
|
||||
const char *path = ptr;
|
||||
|
||||
return (void *)(VALUE)chdir(path);
|
||||
}
|
||||
|
||||
static void
|
||||
dir_chdir(VALUE path)
|
||||
{
|
||||
if (chdir(RSTRING_PTR(path)) < 0)
|
||||
int r;
|
||||
char *p = RSTRING_PTR(path);
|
||||
|
||||
r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p, RUBY_UBF_IO, 0);
|
||||
if (r < 0)
|
||||
rb_sys_fail_path(path);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue