[php-src] PR #20299: Make the FTP extension coroutine-enabled

From: Date: Sun, 26 Oct 2025 06:31:23 +0000
Subject: [php-src] PR #20299: Make the FTP extension coroutine-enabled
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-33814@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/20299 Author: NathanFreeman Hello everyone, I plan to add coroutine support for FTP in Swoole. However, in the current FTP implementation, the use of poll is hardcoded, which lacks flexibility and makes it impossible to coroutine-enable FTP in Swoole. Therefore, I have made the following modifications to the my_poll function in ftp.c: 1. Replaced the direct call to php_pollfd_for_ms with a function pointer named php_ftp_pollfd_for_ms. 2. During the extension initialization phase, the pointer is set to point to the original php_pollfd_for_ms implementation by default, ensuring the existing synchronous logic remains unaffected. 3. When running in a coroutine environment, this function pointer can be replaced with a coroutine-compatible polling function (such as a non-blocking version based on an event loop), thereby achieving non-blocking FTP socket operations for the main thread. This modification does not affect the original FTP logic and introduces no syntactic changes. With this change, I can easily assign a value to php_ftp_pollfd_for_ms in my own extension, enabling coroutine support for FTP without any disruptive intrusions into the FTP code. I have also executed all relevant FTP tests under this modification, and they all pass.

« previous php.git-pulls (#33814) next »