diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp --- a/src/ioslaves/file/file_unix.cpp +++ b/src/ioslaves/file/file_unix.cpp @@ -51,6 +51,12 @@ //sendfile has different semantics in different platforms #if HAVE_SENDFILE && defined Q_OS_LINUX #define USE_SENDFILE 1 +// On Linux, write() (and similar system calls) will transfer at most +// 0x7ffff000 (2,147,479,552) bytes, returning the number of bytes +// actually transferred. (This is true on both 32-bit and 64-bit +// systems.) +// This includes sendfile +#define MAX_SENDFILE_BUFF (0x7ffff000) #endif #ifdef USE_SENDFILE @@ -258,14 +264,14 @@ char buffer[ MAX_IPC_SIZE ]; ssize_t n = 0; #ifdef USE_SENDFILE - bool use_sendfile = buff_src.st_size < 0x7FFFFFFF; + bool use_sendfile = true; #endif bool existing_dest_delete_attempted = false; while (1) { #ifdef USE_SENDFILE if (use_sendfile) { off_t sf = processed_size; - n = ::sendfile(dest_file.handle(), src_file.handle(), &sf, MAX_IPC_SIZE); + n = ::sendfile(dest_file.handle(), src_file.handle(), &sf, MAX_SENDFILE_BUFF); processed_size = sf; if (n == -1 && (errno == EINVAL || errno == ENOSYS)) { //not all filesystems support sendfile() // qDebug() << "sendfile() not supported, falling back ";