[前][次][番号順一覧][スレッド一覧]

ruby-changes:40071

From: kosaki <ko1@a...>
Date: Sun, 18 Oct 2015 08:31:41 +0900 (JST)
Subject: [ruby-changes:40071] kosaki:r52152 (trunk): * io.c (fptr_finalize): don't release gvl if fptr is not writable.

kosaki	2015-10-18 08:31:23 +0900 (Sun, 18 Oct 2015)

  New Revision: 52152

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52152

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/io.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52151)
+++ ChangeLog	(revision 52152)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Oct 18 08:26:51 2015  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* 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
+
 Sun Oct 18 05:11:22 2015  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* ruby.c (open_load_file): reset O_NONBLOCK after open.
Index: io.c
===================================================================
--- io.c	(revision 52151)
+++ io.c	(revision 52152)
@@ -4263,6 +4263,7 @@ fptr_finalize(rb_io_t *fptr, int noraise https://github.com/ruby/ruby/blob/trunk/io.c#L4263
     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 https://github.com/ruby/ruby/blob/trunk/io.c#L4304
 	/* 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);
     }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]