copy: rework how we determine the number of bytes to copy in copy_bytes_full()
authorLennart Poettering <lennart@poettering.net>
Fri, 24 May 2024 10:02:42 +0000 (12:02 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 14 Jun 2024 11:44:28 +0000 (13:44 +0200)
commit22ed8700c7d70419bc74bf1ce187b950ee7b65fd
tree625e19800692c1037fe955b58752a743b68989fb
parent432977a0a4d7c5944fa8ec0f5483c205578e9aea
copy: rework how we determine the number of bytes to copy in copy_bytes_full()

Let's freshly calculate "m" on each iteration and always start with the maximum
size we can. If sendfile() is used we must adhere to its limit of
SSIZE_MAX minus the current offset. Otherwise we can copy more, i.e.
SSIZE_MAX without any restrictions.

Also, if we get too close to having copied SSIZE_MAX, let's turn off
sendfile() for the rest.
src/shared/copy.c