diff options
author | Lukas Larsson <[email protected]> | 2017-06-07 09:51:01 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2017-06-07 09:51:01 +0200 |
commit | 6076b94dd8206806e454b1c6e12ffcd467bc21c5 (patch) | |
tree | c9f0d91c48a72016871cfdc812dd6296ccdd9a77 /erts | |
parent | 106c7b1bd5d845b982796e4ab5d537b2e68c3f1d (diff) | |
parent | 4e38e959a1ecfaa5fa5f3571599a60ab0a88c712 (diff) | |
download | otp-6076b94dd8206806e454b1c6e12ffcd467bc21c5.tar.gz otp-6076b94dd8206806e454b1c6e12ffcd467bc21c5.tar.bz2 otp-6076b94dd8206806e454b1c6e12ffcd467bc21c5.zip |
Merge branch 'lukas/erts/sendfile_sunos_fix/OTP-14424'
* lukas/erts/sendfile_sunos_fix/OTP-14424:
erts: Fix sendfile closeduring scenario on sunos
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/drivers/unix/unix_efile.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/erts/emulator/drivers/unix/unix_efile.c b/erts/emulator/drivers/unix/unix_efile.c index 0acc2432a7..f8341f788a 100644 --- a/erts/emulator/drivers/unix/unix_efile.c +++ b/erts/emulator/drivers/unix/unix_efile.c @@ -969,17 +969,21 @@ efile_sendfile(Efile_error* errInfo, int in_fd, int out_fd, fdrec.sfv_len = SENDFILE_CHUNK_SIZE; else fdrec.sfv_len = *nbytes; + retval = sendfilev(out_fd, &fdrec, 1, &len); - /* Sometimes sendfilev can return -1 and still send data. - When that happens we just pretend that no error happend. */ - if (retval != -1 || errno == EAGAIN || errno == EINTR || - len != 0) { + if (retval == -1 && errno == EINVAL) { + /* On some solaris versions (I've seen it on SunOS 5.10), + using a sfv_len larger then a filesize will result in + a -1 && errno == EINVAL return. We translate this so + a successful send of the data.*/ + retval = len; + } + + if (retval != -1 || errno == EAGAIN || errno == EINTR) { *offset += len; *nbytes -= len; written += len; - if (errno != EAGAIN && errno != EINTR && len != 0) - retval = len; } } while (len == SENDFILE_CHUNK_SIZE); #elif defined(__DARWIN__) |