Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1486 closed Bug (fixed)

Large file support broken on Windows

Reported by: lubomir.marinov Owned by: charles
Priority: Normal Milestone: 1.41
Component: libtransmission Version: 1.40
Severity: Normal Keywords:
Cc:

Description

Files larger than what seems like 2GB cannot be downloaded. While they're initially preallocated, when transmissioncli tries to write actual data beyond the mentioned 2GB limit, they get truncated to a size smaller than the limit in question. Eventually, the files don't finish downloading (well, actually the peers seem to give up on us).

Spry pointed the bigger problem which is the use of ftruncate which isn't available with MSVC and doesn't support large files with MinGW. He also has a patch in his transmission fork but it definitely doesn't suffice with MinGW - off_t isn't large-file aware because its awareness cannot be controlled with a preprocessor define such as _FILE_OFFSET_BITS, _GNU_SOURCE, etc. Moreover, Spry's modifications return errno upon failures of Win32 functions.

The attached patch takes the Spry's ideas and try to complete them with the proposals for fixes of the additional problems outlined above.

Attachments (2)

inout.c-win32-large-file-support.patch (2.9 KB) - added by lubomir.marinov 12 years ago.
Unbreaks large file support on Windows in inout.c
inout.c-cleaned-code.patch (2.9 KB) - added by spry 12 years ago.

Download all attachments as: .zip

Change History (9)

Changed 12 years ago by lubomir.marinov

Unbreaks large file support on Windows in inout.c

comment:1 Changed 12 years ago by charles

lubomir.marinov: actually now that we're preallocating the file, we could get rid of ensureMinimumFileSize, couldn't we?

If that's correct, could you please update your patch... because I trust you to get it working on Windows a lot more than I trust myself. ;)

comment:2 Changed 12 years ago by spry

charles: Yeap, for sure, we need to cut out ensureMinimumFileSize, since we are preallocating. For some reason, I'm not sure that applied patch will work on MSVC builds. Lubomir, could you please cut the ensureMinimumFileSize and a call to it since it's not needed anyway. By the way, for MSVC the lseek line should be this

else if( lseek( fd, fileOffset, SEEK_SET ) == ( -1L ) )

or

else if( lseek( fd, fileOffset, SEEK_SET ) == ( (uint64_t)-1 ) )

seems to me.

Changed 12 years ago by spry

comment:3 Changed 12 years ago by charles

I think both of your ideas are good. :)

I'm not sure that we need to distinguish between -1L and -1 though. Sine _lseeki64 returns a int64, both -1L and -1 will get automatically promoted to a signed 64-bit integer.

comment:4 Changed 12 years ago by charles

bah, silly trac. the double-underline preceeding `int64' didn't do what I expected :)

comment:5 Changed 12 years ago by charles

  • Keywords backport-candidate added
  • Milestone changed from None Set to 1.41
  • Status changed from new to assigned
  • Version set to 1.40

I've checked in new code into r7131. It removes the `preallocate' function as per Spry's patch. I moved the lseek ifdefs into a wrapper function where it won't clutter things up as much.

Please reopen the ticket if I've introduced new win32 breakage with this commit. ;)

comment:6 Changed 12 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:7 Changed 12 years ago by charles

  • Keywords backport-candidate removed

1.4x: r7142

Note: See TracTickets for help on using tickets.