I built a test rig:
$l1 = mysqli_connect();
$l2 = mysqli_connect();
$l3 = mysqli_connect();
$s1 = "SELECT CURTIME()";
$s2 = "SELECT * FROM"; // will error #1064
$s3 = "SELECT SLEEP(10), CURTIME()";
mysqli_query($l1, $s1, MYSQLI_ASYNC);
mysqli_query($l2, $s2, MYSQLI_ASYNC);
mysqli_query($l3, $s3, MYSQLI_ASYNC);
$started=time();
for ($x=0; $x<5; $x++) {
$ready=$reject=$errors = array($l1, $l2, $l3);
print "\niteration $x at t+" . (time()-$started) . "\n";
mysqli_poll($ready, $errors, $reject, 3);
print "ready = " . count($ready) . "\n";
foreach($ready as $r) {
$c=mysqli_reap_async_query($r);
print "err=" . mysqli_error($r) . " cnt=" . count($c) . "\n";
};
print "errors = " . count($errors) . "\n";
print "reject = " . count($reject) . "\n";
sleep(4);
}
Results (annotations prefixed with //):
iteration 0 at t+0
ready = 1 // appears to be SELECT CURTIME()
err= cnt=1
errors = 0
reject = 0
iteration 1 at t+4
ready = 1 // appears to be SELECT * FROM
err=You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '' at line
1 cnt=1
errors = 0
reject = 1 // appears to be SELECT CURTIME() (results reaped)
iteration 2 at t+8
ready = 1 // appears to be SELECT SLEEP(10) despite 8 seconds elapsed
err= cnt=1
errors = 0
reject = 2 // appears to be SELECT CURTIME() + SELECT * FROM
iteration 3 at t+14
ready = 0
errors = 0
reject = 3
iteration 4 at t+21
ready = 0
errors = 0
reject = 3
i.e. $reject is getting populated with links where the results have been reaped, NOT links which are not yet ready to poll.
Trying with with an invalid connection, the value is removed from all arrays (not added to $reject),