summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-17 23:31:23 (GMT)
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-17 23:31:23 (GMT)
commit50024f9da6280c9fe48a4886364bae62d4eef92e (patch)
tree3e10d9c143b567b7ae749f81d59f1c7778728468 /io.c
parentbc8687acd62584bf2ba9a951289f3f25a4de7229 (diff)
* io.c (fptr_finalize): don't release gvl if fptr is not writable.
writable fd may block on close(2) when it's on NFS. But readonly fd doesn't. [Bug #11559] result: make benchmark OPTS="-p bm_require_t -e ruby-trunk -e ruby-2.2.2" build-ruby: 0.171 ruby 2.3.0dev(r52151): 0.659 ruby 2.2.0p95 (r50295): 0.834 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/io.c b/io.c
index b7e3316..682f733 100644
--- a/io.c
+++ b/io.c
@@ -4263,6 +4263,7 @@ fptr_finalize(rb_io_t *fptr, int noraise)
VALUE err = Qnil;
int fd = fptr->fd;
FILE *stdio_file = fptr->stdio_file;
+ int mode = fptr->mode;
if (fptr->writeconv) {
if (fptr->write_lock && !noraise) {
@@ -4303,7 +4304,11 @@ fptr_finalize(rb_io_t *fptr, int noraise)
/* fptr->fd may be closed even if close fails.
* POSIX doesn't specify it.
* We assumes it is closed. */
- if ((maygvl_close(fd, noraise) < 0) && NIL_P(err))
+
+ /**/
+ int keepgvl = !(mode & FMODE_WRITABLE);
+ keepgvl |= noraise;
+ if ((maygvl_close(fd, keepgvl) < 0) && NIL_P(err))
err = noraise ? Qtrue : INT2NUM(errno);
}