Fallback from sendfile64() in case of ENOSYS as well
As suggested on https://man7.org/linux/man-pages/man2/sendfile.2.html.
This commit is contained in:
parent
da91e54ec7
commit
a55a3604bd
|
@ -114,7 +114,7 @@ template <std::size_t bufferSize> void CopyHelper<bufferSize>::copy(NativeFileSt
|
|||
while (count) {
|
||||
const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, count);
|
||||
if (bytesCopied < 0) {
|
||||
if (errno == EINVAL && static_cast<std::uint64_t>(totalBytes) == count) {
|
||||
if ((errno == EINVAL || errno == ENOSYS) && static_cast<std::uint64_t>(totalBytes) == count) {
|
||||
// try again the unoptimized version, maybe the filesystem doesn't support sendfile
|
||||
goto unoptimized_version;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ void CopyHelper<bufferSize>::callbackCopy(NativeFileStream &input, NativeFileStr
|
|||
const auto bytesToCopy = static_cast<std::size_t>(std::min(count, static_cast<std::uint64_t>(bufferSize)));
|
||||
const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, bytesToCopy);
|
||||
if (bytesCopied < 0) {
|
||||
if (errno == EINVAL && static_cast<std::uint64_t>(totalBytes) == count) {
|
||||
if ((errno == EINVAL || errno == ENOSYS) && static_cast<std::uint64_t>(totalBytes) == count) {
|
||||
// try again the unoptimized version, maybe the filesystem doesn't support sendfile
|
||||
goto unoptimized_version;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue