aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-20 02:29:35 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-20 02:29:35 +0000
commit1bfd311b80c238beb19d387e0e537b612e5c6278 (patch)
tree3d98463f150aaf9b6e19effb3f56b0d2ab59e16f /file.c
parentc1a0a09d2b7fb920640857d4ed4b48761b94fb86 (diff)
downloadruby-1bfd311b80c238beb19d387e0e537b612e5c6278.tar.gz
File.mkfifo releases GVL
mkfifo(3) is subject to the same problems as open(2) on slow filesystems. Release the GVL and let the rest of the VM run while we call mkfifo. * file.c (nogvl_mkfifo): new function (rb_file_s_mkfifo): release GVL git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/file.c b/file.c
index 6080bbfd2a..098de7a8de 100644
--- a/file.c
+++ b/file.c
@@ -5752,6 +5752,19 @@ rb_stat_sticky(VALUE obj)
#endif
#ifdef HAVE_MKFIFO
+struct mkfifo_arg {
+ const char *path;
+ mode_t mode;
+};
+
+static void *
+nogvl_mkfifo(void *ptr)
+{
+ struct mkfifo_arg *ma = ptr;
+
+ return (void *)(VALUE)mkfifo(ma->path, ma->mode);
+}
+
/*
* call-seq:
* File.mkfifo(file_name, mode=0666) => 0
@@ -5766,16 +5779,18 @@ static VALUE
rb_file_s_mkfifo(int argc, VALUE *argv)
{
VALUE path;
- mode_t mode = 0666;
+ struct mkfifo_arg ma;
+ ma.mode = 0666;
rb_check_arity(argc, 1, 2);
if (argc > 1) {
- mode = NUM2MODET(argv[1]);
+ ma.mode = NUM2MODET(argv[1]);
}
path = argv[0];
FilePathValue(path);
path = rb_str_encode_ospath(path);
- if (mkfifo(RSTRING_PTR(path), mode)) {
+ ma.path = RSTRING_PTR(path);
+ if (rb_thread_call_without_gvl(nogvl_mkfifo, &ma, RUBY_UBF_IO, 0)) {
rb_sys_fail_path(path);
}
return INT2FIX(0);