gh9590.phpt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --TEST--
  2. Bug GH-9602 (stream_select does not abort upon exception or empty valid fd set)
  3. --EXTENSIONS--
  4. mysqli
  5. posix
  6. --SKIPIF--
  7. <?php
  8. require_once('skipifconnectfailure.inc');
  9. if (!$IS_MYSQLND)
  10. die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd");
  11. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  12. die("skip cannot connect");
  13. if (mysqli_get_server_version($link) < 50012)
  14. die("skip Test needs SQL function SLEEP() available as of MySQL 5.0.12");
  15. if (!function_exists('posix_setrlimit') || !posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1))
  16. die('skip Failed to set POSIX_RLIMIT_NOFILE');
  17. ?>
  18. --FILE--
  19. <?php
  20. posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1);
  21. $fds = [];
  22. for ($i = 0; $i < 1023; $i++) {
  23. $fds[] = @fopen(__DIR__ . "/GH-9590-tmpfile.$i", 'w');
  24. }
  25. require_once('connect.inc');
  26. function get_connection() {
  27. global $host, $user, $passwd, $db, $port, $socket;
  28. if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
  29. printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
  30. return $link;
  31. }
  32. $mysqli1 = get_connection();
  33. $mysqli2 = get_connection();
  34. var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT));
  35. var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT));
  36. $links = $errors = $reject = array($mysqli1, $mysqli2);
  37. var_dump(mysqli_poll($links, $errors, $reject, 0, 50000));
  38. mysqli_close($mysqli1);
  39. mysqli_close($mysqli2);
  40. print "done!";
  41. ?>
  42. --EXPECTF--
  43. bool(true)
  44. bool(true)
  45. Warning: mysqli_poll(): You MUST recompile PHP with a larger value of FD_SETSIZE.
  46. It is set to 1024, but you have descriptors numbered at least as high as %d.
  47. --enable-fd-setsize=%d is recommended, but you may want to set it
  48. to equal the maximum number of open files supported by your system,
  49. in order to avoid seeing this error again at a later date. in %s on line %d
  50. bool(false)
  51. done!
  52. --CLEAN--
  53. <?php
  54. for ($i = 0; $i < 1023; $i++) {
  55. @unlink(__DIR__ . "/GH-9590-tmpfile.$i");
  56. }
  57. ?>