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,11 @@ //sendfile has different semantics in different platforms #if HAVE_SENDFILE && defined Q_OS_LINUX #define USE_SENDFILE 1 +// sendfile() 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.) +// Defaults to 5MB so the user can follow copy progress +#define SENDFILE_CHUNK_SIZE (5 * 1024 * 1024) #endif #ifdef USE_SENDFILE @@ -258,14 +263,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, SENDFILE_CHUNK_SIZE); processed_size = sf; if (n == -1 && (errno == EINVAL || errno == ENOSYS)) { //not all filesystems support sendfile() // qDebug() << "sendfile() not supported, falling back ";