diff options
author | Lukas Larsson <[email protected]> | 2017-05-22 11:25:20 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2017-06-07 09:46:30 +0200 |
commit | 4e38e959a1ecfaa5fa5f3571599a60ab0a88c712 (patch) | |
tree | 223a03c42aa5077837d46c67fee003ea7a6ba88b | |
parent | 05dce0f330c83278cb134c7235a5353ce4116307 (diff) | |
download | otp-4e38e959a1ecfaa5fa5f3571599a60ab0a88c712.tar.gz otp-4e38e959a1ecfaa5fa5f3571599a60ab0a88c712.tar.bz2 otp-4e38e959a1ecfaa5fa5f3571599a60ab0a88c712.zip |
erts: Fix sendfile closeduring scenario on sunos
On Solaris, giving a too long sfv_len results in an
EINVAL error, but data is still transmitted and len is
correctly. So we translate this to a success with that
amount of data sent. This may hide some other errors
that causes EINVAL, but it is the best we can do for now.
-rw-r--r-- | erts/emulator/drivers/unix/unix_efile.c | 16 | ||||
-rw-r--r-- | lib/kernel/test/sendfile_SUITE.erl | 4 |
2 files changed, 12 insertions, 8 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__) diff --git a/lib/kernel/test/sendfile_SUITE.erl b/lib/kernel/test/sendfile_SUITE.erl index 2673c38494..e839959623 100644 --- a/lib/kernel/test/sendfile_SUITE.erl +++ b/lib/kernel/test/sendfile_SUITE.erl @@ -100,13 +100,13 @@ init_per_testcase(TC,Config) when TC == t_sendfile_recvduring; %% Check if sendfile is supported on this platform case catch sendfile_send(Send) of ok -> - Config; + init_per_testcase(t_sendfile, Config); Error -> ct:log("Error: ~p",[Error]), {skip,"Not supported"} end; init_per_testcase(_Tc,Config) -> - Config. + Config ++ [{sendfile_opts,[{use_threads,false}]}]. t_sendfile_small(Config) when is_list(Config) -> |