nroi / flexo

a central pacman cache
MIT License
172 stars 10 forks source link

Make sendfile count min of bytes and max sendfile count #85

Closed ppickfor closed 2 years ago

ppickfor commented 2 years ago

There is an issue with sendfile returning EINVAL under linux 5.16 with zfs https://github.com/openzfs/zfs/issues/12971

As part of the diagnostics it was suggested that sendfile count should not be larger that the file to be sent. It has not fixed the issue with sendfile and 5.16 under zfs but is perhaps more correct than the current code and should not trigger the following case should the kernel maintainers decide to implement this error.

       EOVERFLOW
              count is too large, the operation would result in exceeding the maximum size of either the input file or the output file.

flexo.strace.5.15.txt flexo.strace.5.16.txt

nroi commented 2 years ago

Thanks! I'm not sure why I originally used MAX_SENDFILE_COUNT even if the file is smaller, but even apart from the behavior in zfs, the code in your PR makes more sense than the original code.