Open fullnitrous opened 3 years ago
Also the best way is probably to use io_uring for that too, from liburing:
This splice operation can be used to implement sendfile by splicing to an intermediate pipe first, then splice to the final destination. In fact, the implementation of sendfile in kernel uses splice internally.
And in case it wasn't clear, a comment explains it:
in the io_uring case, you should be able to build a splice-based sendfile yourself using a pipe you create via pipe(2) to act as the buffer. Or do similar via fixed buffers in the ring instead of splice.
Reading the comment above the function
copy_file_contents()
it says the following.But the function itself loads the entire file at once into userspace memory. The function does not use
sendfile()
.