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