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

ruby-changes:21777

From: kosaki <ko1@a...>
Date: Thu, 24 Nov 2011 11:59:15 +0900 (JST)
Subject: [ruby-changes:21777] kosaki:r33826 (trunk): Merge branch 'fsync-nogvl' into trunk

kosaki	2011-11-24 11:57:57 +0900 (Thu, 24 Nov 2011)

  New Revision: 33826

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

  Log:
    Merge branch 'fsync-nogvl' into trunk
    
    Conflicts:
    ChangeLog

  Modified files:
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33825)
+++ ChangeLog	(revision 33826)
@@ -1,3 +1,10 @@
+Thu Nov 24 11:12:48 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* io.c (rb_io_fsync,rb_io_fdatasync): release GVL during fsync().
+	  fsync() and fdatasync() may take a long time on slow disks and/or
+	  if there is much dirty data.
+	  Patch by Eric Wong. [Feature #5665] [ruby-core:41247]
+
 Thu Nov 24 10:05:02 2011  Martin Bosslet  <Martin.Bosslet@g...>
 
 	* test/openssl/test_engine.rb: Suppress output from 'openssl'
Index: io.c
===================================================================
--- io.c	(revision 33825)
+++ io.c	(revision 33826)
@@ -1509,6 +1509,13 @@
 }
 
 #ifdef HAVE_FSYNC
+static VALUE nogvl_fsync(void *ptr)
+{
+    rb_io_t *fptr = ptr;
+
+    return (VALUE)fsync(fptr->fd);
+}
+
 /*
  *  call-seq:
  *     ios.fsync   -> 0 or nil
@@ -1534,7 +1541,7 @@
     if (io_fflush(fptr) < 0)
         rb_sys_fail(0);
 #ifndef _WIN32	/* already called in io_fflush() */
-    if (fsync(fptr->fd) < 0)
+    if ((int)rb_thread_io_blocking_region(nogvl_fsync, fptr, fptr->fd) < 0)
 	rb_sys_fail_path(fptr->pathv);
 #endif
     return INT2FIX(0);
@@ -1544,6 +1551,13 @@
 #endif
 
 #ifdef HAVE_FDATASYNC
+static VALUE nogvl_fdatasync(void *ptr)
+{
+    rb_io_t *fptr = ptr;
+
+    return (VALUE)fdatasync(fptr->fd);
+}
+
 /*
  *  call-seq:
  *     ios.fdatasync   -> 0 or nil
@@ -1566,7 +1580,7 @@
     if (io_fflush(fptr) < 0)
         rb_sys_fail(0);
 
-    if (fdatasync(fptr->fd) == 0)
+    if ((int)rb_thread_io_blocking_region(nogvl_fdatasync, fptr, fptr->fd) == 0)
 	return INT2FIX(0);
 
     /* fall back */

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

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