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

ruby-changes:29030

From: usa <ko1@a...>
Date: Wed, 5 Jun 2013 12:38:44 +0900 (JST)
Subject: [ruby-changes:29030] usa:r41082 (ruby_1_9_3): merge revision(s) 40887,40888,40894,40896: [Backport #8431]

usa	2013-06-05 12:38:28 +0900 (Wed, 05 Jun 2013)

  New Revision: 41082

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

  Log:
    merge revision(s) 40887,40888,40894,40896: [Backport #8431]
    
    * win32/win32.c (setup_overlapped, finish_overlapped): extract from
      rb_w32_read() and rb_w32_write().
    
    * win32/win32.c (setup_overlapped): check the error code in addition
      to the result of SetFilePointer() to determine if an error occurred,
      because INVALID_SET_FILE_POINTER is a valid value.
      [ruby-core:55098] [Bug #8431]

  Modified directories:
    branches/ruby_1_9_3/
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/test/ruby/test_io.rb
    branches/ruby_1_9_3/version.h
    branches/ruby_1_9_3/win32/win32.c

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 41081)
+++ ruby_1_9_3/ChangeLog	(revision 41082)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Wed Jun  5 12:38:14 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/win32.c (setup_overlapped, finish_overlapped): extract from
+	  rb_w32_read() and rb_w32_write().
+
 Wed May 29 21:03:08 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (POSTLINK): default to : command to get rid of flag
Index: ruby_1_9_3/win32/win32.c
===================================================================
--- ruby_1_9_3/win32/win32.c	(revision 41081)
+++ ruby_1_9_3/win32/win32.c	(revision 41082)
@@ -5180,6 +5180,49 @@ rb_w32_close(int fd) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/win32/win32.c#L5180
     return 0;
 }
 
+static int
+setup_overlapped(OVERLAPPED *ol, int fd)
+{
+    memset(ol, 0, sizeof(*ol));
+    if (!(_osfile(fd) & (FDEV | FPIPE))) {
+	LONG high = 0;
+	DWORD method = _osfile(fd) & FAPPEND ? FILE_END : FILE_CURRENT;
+	DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high, method);
+#ifndef INVALID_SET_FILE_POINTER
+#define INVALID_SET_FILE_POINTER ((DWORD)-1)
+#endif
+	if (low == INVALID_SET_FILE_POINTER) {
+	    DWORD err = GetLastError();
+	    if (err != NO_ERROR) {
+		errno = map_errno(err);
+		return -1;
+	    }
+	}
+	ol->Offset = low;
+	ol->OffsetHigh = high;
+    }
+    ol->hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
+    if (!ol->hEvent) {
+	errno = map_errno(GetLastError());
+	return -1;
+    }
+    return 0;
+}
+
+static void
+finish_overlapped(OVERLAPPED *ol, int fd, DWORD size)
+{
+    CloseHandle(ol->hEvent);
+
+    if (!(_osfile(fd) & (FDEV | FPIPE))) {
+	LONG high = ol->OffsetHigh;
+	DWORD low = ol->Offset + size;
+	if (low < ol->Offset)
+	    ++high;
+	SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN);
+    }
+}
+
 #undef read
 ssize_t
 rb_w32_read(int fd, void *buf, size_t size)
@@ -5238,25 +5281,7 @@ rb_w32_read(int fd, void *buf, size_t si https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/win32/win32.c#L5281
 
     /* if have cancel_io, use Overlapped I/O */
     if (cancel_io) {
-	memset(&ol, 0, sizeof(ol));
-	if (!(_osfile(fd) & (FDEV | FPIPE))) {
-	    LONG high = 0;
-	    DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high,
-				       FILE_CURRENT);
-#ifndef INVALID_SET_FILE_POINTER
-#define INVALID_SET_FILE_POINTER ((DWORD)-1)
-#endif
-	    if (low == INVALID_SET_FILE_POINTER) {
-		errno = map_errno(GetLastError());
-		MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
-		return -1;
-	    }
-	    ol.Offset = low;
-	    ol.OffsetHigh = high;
-	}
-	ol.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
-	if (!ol.hEvent) {
-	    errno = map_errno(GetLastError());
+	if (setup_overlapped(&ol, fd)) {
 	    MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
 	    return -1;
 	}
@@ -5310,15 +5335,7 @@ rb_w32_read(int fd, void *buf, size_t si https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/win32/win32.c#L5335
     }
 
     if (pol) {
-	CloseHandle(ol.hEvent);
-
-	if (!(_osfile(fd) & (FDEV | FPIPE))) {
-	    LONG high = ol.OffsetHigh;
-	    DWORD low = ol.Offset + read;
-	    if (low < ol.Offset)
-		++high;
-	    SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN);
-	}
+	finish_overlapped(&ol, fd, read);
     }
 
     ret += read;
@@ -5376,25 +5393,7 @@ rb_w32_write(int fd, const void *buf, si https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/win32/win32.c#L5393
 
     /* if have cancel_io, use Overlapped I/O */
     if (cancel_io) {
-	memset(&ol, 0, sizeof(ol));
-	if (!(_osfile(fd) & (FDEV | FPIPE))) {
-	    LONG high = 0;
-	    DWORD method = _osfile(fd) & FAPPEND ? FILE_END : FILE_CURRENT;
-	    DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high, method);
-#ifndef INVALID_SET_FILE_POINTER
-#define INVALID_SET_FILE_POINTER ((DWORD)-1)
-#endif
-	    if (low == INVALID_SET_FILE_POINTER) {
-		errno = map_errno(GetLastError());
-		MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
-		return -1;
-	    }
-	    ol.Offset = low;
-	    ol.OffsetHigh = high;
-	}
-	ol.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
-	if (!ol.hEvent) {
-	    errno = map_errno(GetLastError());
+	if (setup_overlapped(&ol, fd)) {
 	    MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock));
 	    return -1;
 	}
@@ -5440,15 +5439,7 @@ rb_w32_write(int fd, const void *buf, si https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/win32/win32.c#L5439
     }
 
     if (pol) {
-	CloseHandle(ol.hEvent);
-
-	if (!(_osfile(fd) & (FDEV | FPIPE))) {
-	    LONG high = ol.OffsetHigh;
-	    DWORD low = ol.Offset + written;
-	    if (low < ol.Offset)
-		++high;
-	    SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN);
-	}
+	finish_overlapped(&ol, fd, written);
     }
 
     ret += written;
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 41081)
+++ ruby_1_9_3/version.h	(revision 41082)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 432
+#define RUBY_PATCHLEVEL 433
 
-#define RUBY_RELEASE_DATE "2013-05-29"
+#define RUBY_RELEASE_DATE "2013-06-05"
 #define RUBY_RELEASE_YEAR 2013
-#define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 29
+#define RUBY_RELEASE_MONTH 6
+#define RUBY_RELEASE_DAY 5
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/ruby/test_io.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_io.rb	(revision 41081)
+++ ruby_1_9_3/test/ruby/test_io.rb	(revision 41082)
@@ -2147,4 +2147,35 @@ End https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_io.rb#L2147
       IO.select(tempfiles)
   }, bug8080
   end
+
+  def test_read_32bit_boundary
+    bug8431 = '[ruby-core:55098] [Bug #8431]'
+    make_tempfile {|t|
+      assert_separately(["-", bug8431, t.path], <<-"end;")
+        msg = ARGV.shift
+        f = open(ARGV[0], "rb")
+        f.seek(0xffff_ffff)
+        assert_nil(f.read(1), msg)
+      end;
+    }
+  end if /mswin|mingw/ =~ RUBY_PLATFORM
+
+  def test_write_32bit_boundary
+    bug8431 = '[ruby-core:55098] [Bug #8431]'
+    make_tempfile {|t|
+      assert_separately(["-", bug8431, t.path], <<-"end;", timeout: 30)
+        msg = ARGV.shift
+        f = open(ARGV[0], "wb")
+        f.seek(0xffff_ffff)
+        begin
+          # this will consume very long time or fail by ENOSPC on a
+          # filesystem which sparse file is not supported
+          f.write('1')
+        rescue SystemCallError
+        else
+          assert_equal(0x1_0000_0000, f.tell, msg)
+        end
+      end;
+    }
+  end if /mswin|mingw/ =~ RUBY_PLATFORM
 end

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r40887-40888,40894,40896


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

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