From 1bfd311b80c238beb19d387e0e537b612e5c6278 Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 20 Nov 2017 02:29:35 +0000 Subject: 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 --- file.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'file.c') 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); -- cgit v1.2.3