aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-02-21 06:12:13 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-02-21 06:12:13 +0000
commit7c369b78471e7c847cb4ffdbe95600bca55cabb5 (patch)
treebebf4b38274bb454143a82bd2fd9758b4f9272cf /file.c
parent7c2bbd1c7d40a30583844d649045824161772e36 (diff)
downloadruby-7c369b78471e7c847cb4ffdbe95600bca55cabb5.tar.gz
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
Diffstat (limited to 'file.c')
-rw-r--r--file.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/file.c b/file.c
index bf96ae4e2c..26a5c3c45e 100644
--- a/file.c
+++ b/file.c
@@ -1140,31 +1140,35 @@ typedef struct no_gvl_statx_data {
} no_gvl_statx_data;
static VALUE
-no_gvl_statx(void *data)
+io_blocking_statx(void *data)
{
no_gvl_statx_data *arg = data;
return (VALUE)statx(arg->fd, arg->path, arg->flags, arg->mask, arg->stx);
}
+static void *
+no_gvl_statx(void *data)
+{
+ return (void *)io_blocking_statx(data);
+}
+
static int
-statx_without_gvl(int fd, const char *path, int flags, unsigned int mask, struct statx *stx)
+statx_without_gvl(const char *path, struct statx *stx, unsigned int mask)
{
- no_gvl_statx_data data;
+ no_gvl_statx_data data = {stx, AT_FDCWD, path, 0, mask};
- data.stx = stx;
- data.fd = fd;
- data.path = path;
- data.flags = flags;
- data.mask = mask;
+ /* call statx(2) with pathname */
+ return (int)(VALUE)rb_thread_call_without_gvl(no_gvl_statx, &data,
+ RUBY_UBF_IO, NULL);
+}
- if (path) {
- /* call statx(2) with pathname */
- return (int)(VALUE)rb_thread_call_without_gvl((void *)no_gvl_statx, &data,
- 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
@@ -1177,13 +1181,13 @@ rb_statx(VALUE file, struct statx *stx, unsigned int mask)
if (!NIL_P(tmp)) {
rb_io_t *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;
}
else {
FilePathValue(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);
return result;