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