gh8409.phpt 820 B

12345678910111213141516171819202122232425
  1. --TEST--
  2. GH-8409: Error in socket creation when error handler does not clean persistent connection
  3. --FILE--
  4. <?php
  5. set_error_handler(function (int $errno, string $errstring): never {
  6. trigger_error($errstring, E_USER_ERROR);
  7. });
  8. register_shutdown_function(function (): void {
  9. foreach (get_resources() as $res) {
  10. if (get_resource_type($res) === 'persistent stream') {
  11. echo "ERROR: persistent stream not closed\n";
  12. return;
  13. }
  14. }
  15. echo "OK: persistent stream closed\n";
  16. });
  17. stream_socket_client('tcp://9999.9999.9999.9999:9999', $error_code, $error_message, 0.2, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT);
  18. echo "ERROR: this should not be visible\n";
  19. ?>
  20. --EXPECTF--
  21. Fatal error: stream_socket_client(): %s in %sgh8409.php on line %d
  22. OK: persistent stream closed