ruby-changes:54900
From: nobu <ko1@a...>
Date: Thu, 21 Feb 2019 15:12:19 +0900 (JST)
Subject: [ruby-changes:54900] nobu:r67105 (trunk): Separate fstatx_without_gvl from statx_without_gvl
nobu 2019-02-21 15:12:13 +0900 (Thu, 21 Feb 2019) New Revision: 67105 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67105 Log: Separate fstatx_without_gvl from statx_without_gvl Modified files: trunk/file.c Index: file.c =================================================================== --- file.c (revision 67104) +++ file.c (revision 67105) @@ -1140,31 +1140,35 @@ typedef struct no_gvl_statx_data { https://github.com/ruby/ruby/blob/trunk/file.c#L1140 } 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; - - 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); - } + /* call statx(2) with pathname */ + return (int)(VALUE)rb_thread_call_without_gvl(no_gvl_statx, &data, + RUBY_UBF_IO, NULL); +} + +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, https://github.com/ruby/ruby/blob/trunk/file.c#L1181 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; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/