[php-src] Issue #9065: timeout 200 command

From: Date: Wed, 20 Jul 2022 13:04:51 +0000
Subject: [php-src] Issue #9065: timeout 200 command
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241956@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9065 Author: jabcreations ### Description I've encountered the long execution times of certain commands like gethostbyname (then imagine that in a foreach loop) which don't have any inherent way to limit the execution time...well, not without outright killing the entire PHP process and then throwing an error on top of that. I'm not sure how well it would fit though I think having a universal timeout syntax for commands would be exceptionally useful in this and likely for other PHP commands. In example: $ip = gethostbyname('www.example.com'); Would become: $ip = timeout 200 gethostbyname('www.example.com'); If the gethostbyname command fails to execute in 200ms whatever the command was supposed to return would be either false or null and explicitly not throw an error. In example I'm working on a PHP script that will let me know in real time if my server's IP address has been inappropriately added to a DNSBL however I'm seeing a lot of the servers are no longer up, running or at least responsive, When a server is not responsive for whatever reason I (in this scenario) can simply use a custom function to report a non-responsive server's address for me to remove it from the array. But the main point is that I can manually acknowledge that some part of my code may run slower, disengage that instance and not have PHP come to a crashing halt.

« previous php.bugs (#241956) next »