diff options
author | Lukas Larsson <lukas@erlang-solutions.com> | 2011-11-16 16:05:34 +0100 |
---|---|---|
committer | Lukas Larsson <lukas@erlang-solutions.com> | 2011-12-01 14:10:05 +0100 |
commit | 16b395a11ddc45ee8a36324ed0fb543f4065fc76 (patch) | |
tree | 10485437361536d8125f60d0d310b4a6bceb0307 /erts/emulator | |
parent | ce8fb42d7e92a95666e40614684232d476509cbe (diff) | |
download | otp-16b395a11ddc45ee8a36324ed0fb543f4065fc76.tar.gz otp-16b395a11ddc45ee8a36324ed0fb543f4065fc76.tar.bz2 otp-16b395a11ddc45ee8a36324ed0fb543f4065fc76.zip |
Set chunk size to 3 GB
It is not possible to use the maximum size_t/off_t for the chunks
as that causes sendfile to return einval. 3GB seems to work on all
*nix platforms.
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/drivers/unix/unix_efile.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/erts/emulator/drivers/unix/unix_efile.c b/erts/emulator/drivers/unix/unix_efile.c index dc118c9b9f..8db7f2336e 100644 --- a/erts/emulator/drivers/unix/unix_efile.c +++ b/erts/emulator/drivers/unix/unix_efile.c @@ -1469,6 +1469,8 @@ efile_fadvise(Efile_error* errInfo, int fd, Sint64 offset, } #ifdef HAVE_SENDFILE +#define SENDFILE_CHUNK_SIZE ((1 << 30) -1) + int efile_sendfile(Efile_error* errInfo, int in_fd, int out_fd, off_t *offset, Uint64 *nbytes) @@ -1476,7 +1478,6 @@ efile_sendfile(Efile_error* errInfo, int in_fd, int out_fd, // printf("sendfile(%d,%d,%d,%d)\r\n",out_fd,in_fd,*offset,*nbytes); Uint64 written = 0; #if defined(__linux__) || (defined(__sun) && defined(__SVR4)) -#define SENDFILE_CHUNK_SIZE ((1 << (8*SIZEOF_SIZE_T)) - 1) ssize_t retval; do { // check if *nbytes is 0 or greater than the largest size_t @@ -1488,11 +1489,10 @@ efile_sendfile(Efile_error* errInfo, int in_fd, int out_fd, written += retval; *nbytes -= retval; } - } while (retval == SENDFILE_CHUNK_SIZE); + } while (retval != -1 && retval == SENDFILE_CHUNK_SIZE); *nbytes = written; return check_error(retval == -1 ? -1 : 0, errInfo); #elif defined(DARWIN) -#define SENDFILE_CHUNK_SIZE ((1 << (8*SIZEOF_OFF_T)) - 1) int retval; off_t len; do { @@ -1511,7 +1511,6 @@ efile_sendfile(Efile_error* errInfo, int in_fd, int out_fd, *nbytes = written; return check_error(retval, errInfo); #elif defined(__FreeBSD__) || defined(__DragonFly__) -#define SENDFILE_CHUNK_SIZE ((1 << (8*SIZEOF_SIZE_T)) - 1) off_t len; int retval; do { |