[php-src] PR #20399: IO copy API for stream copying
| From: | bukka | Date: | Wed, 05 Nov 2025 18:32:20 +0000 |
| Subject: | [php-src] PR #20399: IO copy API for stream copying | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33937@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/20399
Author: bukka
This introduces new API for fd copying and modifies
php_stream_copy_to_stream_ex to use
it. The implementation is separated for various platforms and the end result have couple of
implications:
- sendfile is used for copying file to generic fd (e.g. sockets) on linux, bsd, macos and solaris
(it uses sendfilev actually)
- splice is used for copying between generic fds (e.g. sockets) on linux
- copy_file_range should get used on alpine linux with directly using syscall (as musl does not seem
to implement it)
- copy_file_range is used in the loop so it is used multiple times for files bigger than 2GB on
linux
- file mmap for copying is removed as it allowed crashing PHP when another process modified mapped
file - this was used as a fallback for file copying which is no longer needed and sendfile is used
for file copying to stream which should be also more effective
- TransmitFile is used on Windows for copying file to generic fd (socket)
- file to file copying was also optimized on Windows with use of ReadFile and WriteFile.