From: Tanaka Akira Date: 2010-06-27T13:24:44+09:00 Subject: [ruby-core:30915] Re: [Bug #3484] IO.copy_stream w/sendfile fails on large files under 32-bit 2010/6/26 Eric Wong : > > When IO.copy_stream uses sendfile() under 32-bit Linux, it fails for > large files (>2G) because a single sendfile() is limited to the maximum value > of ssize_t (LONG_MAX). Attached is a short patch that breaks up large sendfile() > calls and reuses the existing retry logic. Thank you for the fix. A script to reproduce the problem (for the record): % cat z.rb require 'socket' s = Addrinfo.tcp("127.0.0.1", 0).listen len = 4*1024*1024*1024 th = Thread.new { t, _ = s.accept buf = "" n = 0 while t.read(65536, buf) n += buf.length end if n == len p :success else p [:failure, len, n] end } u = s.connect_address.connect open("/tmp/bigtmp", "w") {|f| f.seek len-1 f.print "a" } IO.copy_stream("/tmp/bigtmp", u) u.close th.join % ./ruby -v z.rb ruby 1.9.3dev (2010-06-27 trunk 28448) [i686-linux] [:failure, 4294967296, 0] -- Tanaka Akira