Separate fstatx_without_gvl from statx_without_gvl
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7c2bbd1c7d
commit
7c369b7847
36
file.c
36
file.c
@ -1140,31 +1140,35 @@ typedef struct no_gvl_statx_data {
|
|||||||
} no_gvl_statx_data;
|
} no_gvl_statx_data;
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
no_gvl_statx(void *data)
|
io_blocking_statx(void *data)
|
||||||
{
|
{
|
||||||
no_gvl_statx_data *arg = data;
|
no_gvl_statx_data *arg = data;
|
||||||
return (VALUE)statx(arg->fd, arg->path, arg->flags, arg->mask, arg->stx);
|
return (VALUE)statx(arg->fd, arg->path, arg->flags, arg->mask, arg->stx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void *
|
||||||
statx_without_gvl(int fd, const char *path, int flags, unsigned int mask, struct statx *stx)
|
no_gvl_statx(void *data)
|
||||||
{
|
{
|
||||||
no_gvl_statx_data data;
|
return (void *)io_blocking_statx(data);
|
||||||
|
}
|
||||||
|
|
||||||
data.stx = stx;
|
static int
|
||||||
data.fd = fd;
|
statx_without_gvl(const char *path, struct statx *stx, unsigned int mask)
|
||||||
data.path = path;
|
{
|
||||||
data.flags = flags;
|
no_gvl_statx_data data = {stx, AT_FDCWD, path, 0, mask};
|
||||||
data.mask = mask;
|
|
||||||
|
|
||||||
if (path) {
|
|
||||||
/* call statx(2) with pathname */
|
/* call statx(2) with pathname */
|
||||||
return (int)(VALUE)rb_thread_call_without_gvl((void *)no_gvl_statx, &data,
|
return (int)(VALUE)rb_thread_call_without_gvl(no_gvl_statx, &data,
|
||||||
RUBY_UBF_IO, NULL);
|
RUBY_UBF_IO, NULL);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return (int)(VALUE)rb_thread_io_blocking_region(no_gvl_statx, &data, fd);
|
static int
|
||||||
}
|
fstatx_without_gvl(int fd, struct statx *stx, unsigned int mask)
|
||||||
|
{
|
||||||
|
no_gvl_statx_data data = {stx, fd, NULL, AT_EMPTY_PATH, mask};
|
||||||
|
|
||||||
|
/* call statx(2) with fd */
|
||||||
|
return (int)rb_thread_io_blocking_region(io_blocking_statx, &data, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1177,13 +1181,13 @@ rb_statx(VALUE file, struct statx *stx, unsigned int mask)
|
|||||||
if (!NIL_P(tmp)) {
|
if (!NIL_P(tmp)) {
|
||||||
rb_io_t *fptr;
|
rb_io_t *fptr;
|
||||||
GetOpenFile(tmp, fptr);
|
GetOpenFile(tmp, fptr);
|
||||||
result = statx_without_gvl(fptr->fd, NULL, AT_EMPTY_PATH, mask, stx);
|
result = fstatx_without_gvl(fptr->fd, stx, mask);
|
||||||
file = tmp;
|
file = tmp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FilePathValue(file);
|
FilePathValue(file);
|
||||||
file = rb_str_encode_ospath(file);
|
file = rb_str_encode_ospath(file);
|
||||||
result = statx_without_gvl(AT_FDCWD, RSTRING_PTR(file), 0, mask, stx);
|
result = statx_without_gvl(RSTRING_PTR(file), stx, mask);
|
||||||
}
|
}
|
||||||
RB_GC_GUARD(file);
|
RB_GC_GUARD(file);
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user