mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Release GVL around system calls in dir.c
* Release GVL for fdopendir calls * Release GVL for readdir calls * Release GVL for chdir call in dir_chdir0 * Release GVL for fchdir call in dir_fchdir * Release GVL for chroot calls * Release GVL for lstat calls * Release GVL for stat calls * Release GVL for fstatat calls * Release GVL for getpwnam call in rb_home_dir_of (technically in file.c, but called from dir.c) This does not release GVL for readdir/stat/lstat on Windows, as that causes issues because the emulation functions that are called in win32.c require the GVL. This also removes some explicit casts either to or from void *, which are allowed implicitly. The remaining casts to or from void * are part of function pointer casts, which are not allowed implicitly and will generate a warning.
This commit is contained in:
parent
949573028b
commit
8ade9994bf
2 changed files with 97 additions and 16 deletions
10
file.c
10
file.c
|
@ -3690,6 +3690,14 @@ copy_home_path(VALUE result, const char *dir)
|
|||
return result;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
static void *
|
||||
nogvl_getpwnam(void *login)
|
||||
{
|
||||
return (void *)getpwnam((const char *)login);
|
||||
}
|
||||
#endif
|
||||
|
||||
VALUE
|
||||
rb_home_dir_of(VALUE user, VALUE result)
|
||||
{
|
||||
|
@ -3712,7 +3720,7 @@ rb_home_dir_of(VALUE user, VALUE result)
|
|||
}
|
||||
|
||||
#ifdef HAVE_PWD_H
|
||||
pwPtr = getpwnam(username);
|
||||
pwPtr = (struct passwd *)IO_WITHOUT_GVL(nogvl_getpwnam, (void *)username);
|
||||
#else
|
||||
if (strcasecmp(username, getlogin()) == 0)
|
||||
dir = pwPtr = getenv("HOME");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue